Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: “My Threads” – User Specific Views


_ck_
Participant

@_ck_

Er, wait a minute. This new view registation method takes away massive potential from views.

For example you can’t manipulate the data before and/or after the BB_QUERY.

Here’s how I find “most viewed” and “least viewed” topics and create new views for them. How the heck is this even remotely possible with the new method? The new method also takes away all natural mysql query methods, making things much more complicated and easier to make mistakes on query configuration.

function most_views( $view ) {
global $bbdb, $topics, $view_count;
if ($view=='most-views') {$sort="DESC";}
if ($view=='least-views') {$sort="ASC";}
if ($view=='least-views' || $view=='most-views') {
$limit = bb_get_option('page_topics');
$where = apply_filters('get_latest_topics_where','');
$most_views = $bbdb->get_results("SELECT topic_id FROM $bbdb->topicmeta WHERE meta_key='views' ORDER BY cast(meta_value as UNSIGNED) $sort LIMIT $limit");
foreach (array_keys($most_views) as $i) {$trans[$most_views[$i]->topic_id] =& $most_views[$i];} $ids = join(',', array_keys($trans));
$topics ="SELECT * FROM $bbdb->topics WHERE topic_status=0 AND topic_id IN ($ids) $where ORDER BY FIELD(topic_id, $ids)";
$topics = $bbdb->get_results($topics);
$view_count = count($topics);
$topics = bb_append_meta( $topics, 'topic' );
}}

.

Absolutely no way to do that purely though BB_QUERY, at least to my limited knowledge. You’d have to hook BB_QUERY and check for what it’s doing on every call and that’s nasty.

Skip to toolbar