Search

bbPress Showcase » Plugins by _ck_

BB Topic Views problem

RSS
  1. Bocete
    User has not uploaded an avatar

    new member
    Joined: Dec '10
    Posts: 1

    offline

    Hey _ck_,

    The plugin works as intended for topic views. However, I've got trouble with forum view counts.

    I've copied the 'forums_views_append' function to the php file (renamed to 'forums_views_appendaa' because of some name conflict) of the plugin, and I've added add_filter('get_forums','forums_views_appendaa');

    I've called 'var_dump(get_object_vars($forum));' instead of 'echo $forum->views' inside the views cell in forum.php, giving me output

    array(9) {
    ["forum_id"]=> string(1) "2"
    ["forum_name"]=> string(6) "Ostalo"
    ["forum_slug"]=> string(6) "ostalo"
    ["forum_desc"]=> string(37) "Sve što ne spada u ostale kategorije"
    ["forum_parent"]=> string(1) "0"
    ["forum_order"]=> string(1) "8"
    ["topics"]=> string(1) "0"
    ["posts"]=> string(1) "0"
    ["forum_is_category"]=> string(1) "1"
    }

    Clearly no 'views' field has been defined in the filter function.

    That function is being called properly, as it echoes if I insert an echo command. I've found that the $forums_views variable is empty after the SQL call, which indeed creates no 'views' field in $forum. However, I'm lost on what to do next. Hopefully you can help me out.

    Here's the filter function:
    function forums_views_appendaa($forums) {
    global $bbdb; $sum_meta_value="SUM(meta_value)";
    $forums_views = $bbdb->get_results(" SELECT $sum_meta_value,forum_id FROM $bbdb->topicmeta LEFT JOIN $bbdb->topics ON $bbdb->topicmeta.topic_id = $bbdb->topics.topic_id WHERE $bbdb->topicmeta.meta_key='views' GROUP BY $bbdb->topics.forum_id");
    print_r ($forums_views);
    foreach ($forums_views as $forum_views) {
    $forums[$forum_views->forum_id]->views=$forum_views->$sum_meta_value;
    }
    echo 'filter executed';
    return $forums;
    }

    Cheers,
    Bo

    Posted 1 year ago #

RSS feed for this topic

Post a reply to “BB Topic Views problem”

You must log in to post.

keep _ck_ coding >> donate $5 <<     Theme Switcher:
43 users online from in the past 30 minutes. 18 bots 25 guests
3,516 views today 8,638 yesterday 16,043 peak. Most at once 47 today 60 yesterday 131 peak. Visited today: qamilon, pandoracam, lvgalliera
2,288 posts in 394 topics over 66 months by 430 of 2,165 members. Latest: qwe12345100, Janvelden, watchessaleus