How to select only guest visible threads?
I am creating a plugin to show the top threads on the index page, and now instead of running the query by each user, I will do it on a task and cache it to be shown by the index hook.

I was using the query below, but I would like to show only threads that are visible to guests, so that I can keep one single version of the topposts.

How can I achieve this?

Quote:$query = $db->query ("
SELECT t.subject,t.username,t.uid,t.tid,t.fid,t.lastpost,t.lastposter,t.lastposteruid,t.replies, t.views,tr.uid AS truid,tr.dateline, ,
TRUNCATE(t.totalratings/t.numratings*2+t.numratings/8+tyl_tnumtyls+t.replies+t.views/15,2) ranking
FROM ".TABLE_PREFIX."threads t
LEFT JOIN ".TABLE_PREFIX."threadsread tr ON (tr.tid=t.tid AND tr.uid='".$mybb->user['uid']."')
LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid = t.fid)
WHERE t.visible='1'
AND t.closed NOT LIKE 'moved|%'
AND t.dateline >=UNIX_TIMESTAMP()-(86400*".$days.") ORDER BY ranking DESC
LIMIT 0,".$NumOfRows);

Messages In This Thread
How to select only guest visible threads? - by blogantinom - 05-17-2013, 10:51 PM

Forum Jump:

Users browsing this thread: 1 Guest(s)