Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'code'

Viewing 25 results - 26,851 through 26,875 (of 32,495 total)
  • Author
    Search Results
  • #4022
    meitershaker
    Member

    Hi,

    i have a problem with this plugin: http://bbpress.org/plugins/topic/bb-smilies/

    i don’t see the smilies’s toolbar on edit-post pages :( (but it’s works great with a new topic or new post for example)

    why?

    byeee.

    #67646
    _ck_
    Participant

    Off the top of my head this looks like a very bad idea performance-wise:

    AND NOT p.topic_id IN (SELECT t.topic_id FROM bb_topics
    AS t WHERE t.topic_status <> '0')

    Though mysql may optimize it on the fly. Technically there could be thousands of deleted topics on an active site which makes quite a few items to search for (though in your case, there are NO deleted topics, yet, so this won’t be problem early on). However I think topic_status has an index? If not, it’s even worse.

    Alternatively you could “over-search” the results (ie. ask for 100 instead of 30) and reverse the check of the 100 topic_id’s to make sure topic_status=0.

    Since you’d end up using two queries, you could merge the two needs, to check titles AND to check topic status for the previously returned list of posts.

    You’re dead right about pagination becoming insanely complicated in this case. This could be solved by limiting result lengths to just 100 items max, and then use my “over-query” idea to ask for 200 just incase it hits alot of deletions.

    #67645
    Mark Barnes
    Member

    Full text search is of course still quicker and getting rid of the GROUP BY helps even further. 66% quicker in my case. I’m going to use the following query as my search.

    SELECT p . * , MATCH (p.post_text) AGAINST ('test') AS
    search_score FROM bb_posts AS p WHERE MATCH
    (p.post_text) AGAINST ('test') AND p.post_status = '0'
    AND NOT p.topic_id IN (SELECT t.topic_id FROM bb_topics
    AS t WHERE t.topic_status <> '0') ORDER BY search_score
    DESC LIMIT 30;

    The downside is that it doesn’t include topic titles in the search. You can solve this adding this search to a temporary table, running another search on topic_title, and merging the two tables together. You need quite a bit of PHP code to manage this (particularly getting the NEXT buttons to work correctly), but it’s quite possible.

    #67644
    Mark Barnes
    Member

    @sambauers: Let me just give you a couple of observations. Firstly, regarding the first search performed.

    SELECT p.*, 0 AS search_score, MAX(post_time) AS post_time FROM bb_posts AS p JOIN bb_topics as t ON ( t.topic_id = p.topic_id ) WHERE p.post_text LIKE '%test%' AND p.post_status = '0' AND t.topic_status = '0' GROUP BY t.topic_id ORDER BY p.post_time DESC LIMIT 5;

    The first thing that can be done here is remove the join and replace it with a sub-query. This way the sub-query can be cached, and speed is much improved. Here’s the idential query without the join:

    SELECT p.*, 0 AS search_score, MAX(post_time) AS post_time FROM bb_posts AS p WHERE p.post_text LIKE '%test%' AND p.post_status = '0' AND NOT p.topic_id IN (SELECT t.topic_id FROM bb_topics AS t WHERE t.topic_status <> '0') GROUP BY p.topic_id ORDER BY p.post_time DESC LIMIT 5

    That cuts execution time by 55% on my setup. If you have lots of deleted topics this might not apply, but if you have a huge database you ought to be cleaning the deletes out of it regularly anyway.

    _ck_ is also right that ordering by post_id is quicker than by post_time. 17% quicker in my case.

    #4019

    Topic: replacing page title

    in forum Plugins
    Olaf Lederer
    Participant

    Hi,

    I’m busy with some plugin that will do some SEO tasks for bbpress.

    On thing seem to be harder than I thought. I would like to write new page titles in some circumstances. The next “filter” code doesn’t work:

    remove_filter('bb_get_header', 'bb_get_title');
    apply_filters('bb_get_title', 'PHP Scripts Development Forum');

    which function is called before I need to use the remove filter funtion? (the guy from the WP SEO plugin is using some str_replace function, very strange)

    Thanks

    #65946
    byles
    Member

    I apologise – was writing it from memory and in a rush! :) (excuses excuses ;))

    I personally needed to use href to append more to the end.

    I’ve just noticed that the post prior to mine is months old anyway, I guess he figured it out in the end!

    #65945
    _ck_
    Participant

    no, bb_get_profile_link does not self echo but it does return a full formed url apparently, so I was half wrong to use it inside of a href.

    The direct link is via get_user_profile_link( $id )

    byles, your code is wrong in that it doesn’t need an echo

    <?php bb_profile_link('link text here'); ?>

    #65944
    byles
    Member

    bb_get_profile_link does self echo, so you could try:

    <a href="<?php echo user_profile_link(bb_get_current_user_info('id')); ?>/">

    …or if you don’t want to use it amongst another href, just use:

    <?php echo bb_profile_link('link text here'); ?>

    #67691

    In reply to: My code is showing :P

    supermitten
    Member

    i figured out the problem!!

    I just had a bunch of repeated text that did a great job of looking like it should have been there.

    thanks!

    #67705

    In reply to: Extending BB_Locale

    andersson
    Participant

    Well, just to tell anyone who – in the future – might be stuck on the same or a similar problem.

    I went with the following workaround:

    Find a hook (action/filter) that gets called early in the process like bb_location.

    Define a filter function for it.

    In that function, add the following peace of code.

    global $bb_locale;

    $bb_locale->datetime_formatstring = __(‘j M, Y’);

    Obviously, you can call your time format something else.

    Not the prettiest of solutions, but it works and I get to keep my bb_press installation free of code that I’ll surely forget to update.

    #67703
    _ck_
    Participant

    There is a bug in the older template you are using.

    Find these line in your header.php in your template folder:

    <?php bb_enqueue_script('topic'); bb_head(); ?>
    <?php endif; ?>

    and change it to this:

    <?php bb_enqueue_script('topic'); ?>
    <?php endif; ?>
    <?php bb_head(); ?>

    #58267

    In reply to: bbSync

    benzilla069
    Member

    Hi I do have a version working(I downgraded bbpress to the last version bbsync worked because I was tired of using a alpha version of bbpress) it’s completely new code, but it’s very basic on the feature set and a bit hacked together, as I could never get the bbpress functions to work in a wordpress plugin.

    I’m at a public library at the moment so I don’t have the code with me but I can work on the code a little bit when I get home.

    Also please note, this was just made for me and I probably have different needs to what you needed, for example I wanted all wordpress posts to make a new topic so there isn’t options on a per post basis to post to a forum. Also comments don’t replicate between bbpress and wordpress(I was just going to disable commenting and make all users use the topic) but depending on how much time I have tonight I might add this functionality as I don’t see the difficulty in it.

    Also F.Y.I. if anyone is interested I do it the úber ghetto way and manually manipulate the database and don’t go through any of the wordpress or bbpress functions so use at your own risk, but I haven’t run into any problems on my test site.

    #58266

    In reply to: bbSync

    fel64
    Member

    Maybe it’s accidentally eating the comments? I can’t remember.

    Also, hey, look at that – september has almost rolled through and it’s still very, very broken.

    Maybe Benzilla can help you? In any case, the basic ideas are pretty obvious in bbsync; just create meta-entries for each sync’d item on both sides, so you can use them in functions to make links and the like. Comments -> posts just uses a standard comments hook and the bb api to create a post. If I were trying to fix this I’d probably go back to basics and work it again from there, using the old (bad) code as a reference only; that could be the approach to take with this.

    #65357

    In reply to: User Photo for bbPress

    Detective
    Member

    I have uploaded this plugin to the Plugin Repository.

    I found some problems in the earlier version, but it now works :)

    https://bbpress.org/plugins/topic/user-photo-for-bbpress/

    #4014
    andersson
    Participant

    Is there a way to extend BB_Locale?

    Today, BB_Locale calls init and that’s that. No hooks/event handling at all, as far as I can tell.

    In method init, among other things, the following loads:

    $this->datetime_formatstring['datetime'] = __('F j, Y - h:i A');

    $this->datetime_formatstring['date'] = __('F j, Y');

    $this->datetime_formatstring['time'] = __('h:i A');

    The Question

    What if anything can I do if I want to have a datetime_formatstring['special-date'] = __('Y F j - h'); added to BB_Locale. I’m using the three existing formats as listed above already and I want to add a fourth alternative without adding a row in core BB-files.

    Just to be clear, I want to be able to do this:

    _e("Today's date, formatted in a special way is:") . bb_datetime_format_i18n( bb_current_time(), 'special-date' );

    Am I missing something obvious here or is the only solution right now to modify the locale.php file?

    Appreciate the help.

    #67697
    gimperdaniel
    Member

    Thanks chrishajer.. I will take a look. bbSync seems good.. i just read too many comments of people complaining about it… but maybe they don’t know how to use it :)

    I will give it a try this next couple of weeks and let you know of results.

    #67698
    chrishajer
    Participant

    If you include bb-load.php in that file, you will have access to bbpress functions. Why not do something like this in that page:

    require_once(/full/path/to/bbpress/bb-load.php)

    #4012
    #67690

    In reply to: My code is showing :P

    chrishajer
    Participant

    It’s not there now. Maybe you resolved it?

    The bb-config.php might have been missing the beginning <?php or maybe the web server was not configured to parse .php files?

    #67692
    _ck_
    Participant

    It’s because you are destroying $user_id

    This is wrong:

    $user_id = bb_get_user( $user_id );
    $bb_twitter = $user_id->social_twitter;

    You should do:

    $user = bb_get_user( $user_id );
    $bb_twitter = $user->social_twitter;

    $user_id holds the id number, not the entire user object.

    #4010

    Hi,

    I can not figure out what is causing one function in a plugin I am trying to make (modify) to cancel out another function from the same plugin on the same page.

    OK, did that make sense.

    Here are my examples.

    bbSocialize – IF (and this is only an example) I want to display all the information from bbSocialize at the top of the profile and at the bottom of the profile, then it is ONLY displayed at the top (canceling the one one the bottom).

    Avatar Upload – I can put the code in to display my avatar as many times as I want and it shows all of them.

    I am not understanding why the bbSocialize code or functions are causing the second one to cancel out.

    That is basically my problem.

    I have modified bbSocialize in the sense that I have added A LOT to it including customizable fields. What I would like to do is have 2 or 3 functions pulling out certain information so that instead of all that info (or whatever you choose) being displayed in one area, you could break it up on the profile page and put some up top, some down on bottom, some in the middle or possibly floating to the right…..whatever. And of course the main function would be available to display all your selections.

    I hope I made that clear enough.

    Almost like the functions are not closing properly — but I really don’t know.

    Ok, here is the basic bbsocialize funtion to display on the profile page.

    // The following function can be used to display profiles on user-profile-page
    function get_socialize() {
    global $user_id, $bb_current_user, $bb_socialize;

    $user_id = bb_get_user( $user_id );

    $bb_twitter = $user_id->social_twitter;

    echo '<div class="socialize_wrap">';
    if ( $bb_socialize['twitter'] == true ) { if ( !empty( $bb_twitter ) ) { echo '<dd><img src="'.$bb_socialize['images_url'].'/bb_twitter.png" width="16" height="16" border="0" /> <a href="http://twitter.com/'.$bb_twitter.'" title="User Twitter account" rel="'.$bb_socialize['links_rel'].'"><span>'.$bb_twitter.'</span></a></dd>'; } }

    echo '</div>';
    }

    #67643
    _ck_
    Participant

    Remember, the problem with MATCH AGAINST is it will not do partial words or words under 4 characters.

    It’s not too hard to replace the search, you just have to decide which way you want to go. The regular expression will at least do 3 character words which I find is more common than you’d imagine.

    The problem is that the time for any way without an index is going to increase dramatically once you start adding sorting and other options that cause full table scans. You can see this happen if you try to add a simple option to the regex demo like sorting by reverse post_id (which is a trick that should be a little faster than sorting by date).

    SELECT * FROM bb_posts WHERE post_text LIKE '%test%' LIMIT 5 ORDER BY post_id DESC;

    and

    SELECT * FROM bb_posts WHERE post_text LIKE '%test%' AND REGEXP ':<:%test%:>:' LIMIT 5 ORDER BY post_id DESC;

    You might want to test a worse case scenario by using three character nonsense words that will cause a cache-miss like “zzz” and “aaa”. Change them each time so mysql cannot cache the results and give you faster times.

    If the above example returns in an acceptable amount of time you can just replace bbpress’s built in search with that simple method. By parsing a query you can also AND words together instead of bbPress’s default OR which to me is incredibly annoying and useless (you’ll notice no major search engine like Yahoo or Google does OR by default).

    #4009
    supermitten
    Member

    Some of the code for bb-config. php is showing at the top of my bulletin board.

    http://www.comicbooksyndicate.com/syndicatebb/

    How do I get rid of this?

    #67266
    meitershaker
    Member

    please, i would like to understand my error in the code :(

    #67642
    Mark Barnes
    Member

    @_ck_:

    I currently have:

    have_query_cache: YES

    query_cache_limit 1048576

    query_cache_min_res_unit 4096

    query_cache_size 16777216

    query_cache_type ON

    query_cache_wlock_invalidateOFF

    though I’ve got plenty of RAM to tweak this. I don’t want to just throw RAM at poorly optimised queries though.

    The simple query you mentioned takes 2 seconds for me (uncached). MATCH AGAINST with a full-text index takes 0.3 seconds. Keeping a full-text index only increased the database size by 30% in my case. That’s well worth while in the days where disk space is so cheap. The regular expression executes even quicker (0.2s), but as you say does not do partial words.

    There’s no reason why the core can’t have an option for full-text in the settings page, with two different search methods depending on what is chosen. It would only take 20 or so lines of code.

Viewing 25 results - 26,851 through 26,875 (of 32,495 total)
Skip to toolbar