Skip to:
Content
Pages
Categories
Search
Top
Bottom

bbPress – using bb_top_topics()

  • @mithrandir321

    Member

    Hello, I have this code (which comes from another support thread here) on my front-page.php:

    <table id=”highest”>

    <?php $top_topics = bb_top_topics(); ?>

    <?php foreach ( $top_topics as $topic ) : ?> // line 70

    <tr<?php topic_class(); ?>>

    <td>“><?php topic_title(); ?>

    </td>

    <td class=”num”><div class=”rating-holder”><?php bb_rating();?>

    <span class=”count”><?php bb_rating_count(); ?>

    </span>

    </div>

    </td></tr>

    <?php endforeach; ?>

    </table>

    And under it the code for latest topics.

    It gives me this error:

    Warning: Invalid argument supplied for foreach() in /home/home1/novapojistovna_cz/public_html/www/bbpress/bb-templates/kakumei/front-page.php on line 70

    Can anybody help, please. Don’t quite understand what is wrong :-(

    Thanks

Viewing 10 replies - 1 through 10 (of 10 total)
  • @mithrandir321

    Member

    After much research it seems the view ‘top-rated’ gives no results. I checked the DB and found noplace where ratings are stored. It’s really mind-boggling and a little over the top for my knowledge :-(

    Can anybody please help. I have the latest bbPress 1.0-alpha-2 and bbRatings 0.8.5

    @_ck_

    Participant

    Try replacing this line #205

    if ( $topics = (array) $bbdb->get_col("SELECT topic_id FROM $bbdb->topicmeta WHERE meta_key = 'rating'") ) :

    with this one for 1.0 compatibility:

    if ( $topics = (array) $bbdb->get_col("SELECT object_id as topic_id FROM $bbdb->meta WHERE object_type='bb_topic' AND meta_key='rating'") ) :

    and use the admin menu to do a recount of ratings.

    @_ck_

    Participant

    Upon further examination, function bb_rating_init() { may need further modifications under bbPress 1.0

    Unfortunately I am unfamiliar with what to do with that query under 1.0 so mdawaffe may have to do it.

    Just a complete guess, you can try changing line #94:

    $query_args = array( 'meta_key' => 'avg_rating', 'order_by' => '0 + tm.meta_value' );

    to

    $query_args = array('object_type'=>'bb_topic', 'meta_key' => 'avg_rating', 'order_by' => '0 + tm.meta_value' );

    @_ck_

    Participant

    Total shot in the dark here as I can’t debug this code but try replacing in your routine above:

    <?php // $top_topics = bb_top_topics(); ?>

    with

    <?php // $top_topics = bb_top_topics();
    global $bbdb;
    $where = apply_filters('get_latest_topics_where','WHERE topic_status=0');
    $query = "SELECT * FROM $bbdb->topics LEFT JOIN $bbdb->meta ON object_id=topic_id $where AND object_type='bb_topic' AND meta_key='avg_rating' ORDER BY cast(meta_value as UNSIGNED) DESC LIMIT 10";
    $top_topics = bb_append_meta($bbdb->get_results($query),'topic');
    ?>

    @mithrandir321

    Member

    Well, your shots are spot on _CK_. Many many thanks. Hope this helps lots of other newcomers as well.

    @mithrandir321

    Member

    _CK_: sorry to bother you again, I’m sure you know the answer and I just can’t resist asking. How would the code change if I wanted to list the Forum along the top rated topics?

    If you get round taking a look at it I’d be very grateful.

    @mithrandir321

    Member

    Doh, now the rating itself – bb_rating_dingus() – doesn’t work. I can click on a star, but it doesn’t go into the database :-(

    Another thing I noticed, we’ve got different line numbers so maybe you have a different version from mine?

    @mithrandir321

    Member

    Another thing I’ve just noticed – plugin rating on this site doesn’t work either. It says

    Your attempt to do this has failed.

    Please try again.

    @mithrandir321

    Member

    well, one more piece of info – on my site, rating works in IE (with automatic page refresh) and it doesn’t in FF (it used to work, but without automatic page refresh) but also I can’t now login into this bbPress support forum from FF and it doesn’t give any error – weird things going on now

    @mithrandir321

    Member

    Jeez, the thing why I couldnt log in was caused by year long cookie plugin. Deleted it and its okay now…

    The thing with rating in FF persists though :-(

Viewing 10 replies - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.
Skip to toolbar