View Full Version : how to show a list of random threads on every page
Marcel Lee
07-31-2008, 01:40 AM
I want to have a list of (12) random threads (their linked titles) show-up at the top of every page, with the threads changing either like every 24 hours (for a sort of "random threads of the day" theme) or; preferably, and if it isn't too much of a server load; every time a page is refreshed.
Is that possible?
RLShare
07-31-2008, 03:27 AM
Create a plug-in hooked in global-start with this code and then place $threadlist where ever you want the list displayed. The list is not formatted, it just puts each link on a new line, so you will have to do some formatting. Also It will add 1 query to every page.
$threadlist='';
$last_threads = $vbulletin->db->query("SELECT DISTINCT(threadid), title FROM " . TABLE_PREFIX . "thread ORDER BY rand() LIMIT 0,12");
while ($mthreads = $vbulletin->db->fetch_array($last_threads))
{
$threadlist.= "<a href=\"showthread.php?t=$mthreads[threadid]\">".fetch_trimmed_title($mthreads[title])."</a><br />";
}
Marcel Lee
07-31-2008, 09:30 PM
No need to format. You have it exactly how I want.
You also have no idea how much you helped me. Thanks!
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.