Forum Replies Created
-
In reply to: Conforming bbPress to my website
Hey ,
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;
}
In reply to: Conforming bbPress to my websiteHey ,
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;
}