How to create &quot…
 
Notifications
Clear all

How to create "Latest Threads" / "Recent Threads" Widget

1 Posts
1 Users
0 Reactions
146 Views
(@cipher5)
Posts: 152
Member Admin
Topic starter
 

I attached a text file with the code in it because if I paste it in my post here the PHP code block box will stretch out and it’s hard to read.

Here is how to create your own latest thread vbcms widget:
Navigate to AdminCP -> CMS -> Widgets.
Create a PHP Type Widget and paste the below code.

[PHP]
ob_start();
global $vbulletin, $db;
//Begin Thread Counts
$toutput=”;
$recent_threads = $vbulletin->db->query_read(“
SELECT thread.threadid, thread.title, thread.dateline, thread.lastpost, thread.lastposter, thread.lastposterid, thread.visible, thread.open, thread.postusername, thread.postuserid, thread.replycount, thread.views, forum.forumid, forum.title as forumtitle
FROM ” . TABLE_PREFIX . “thread AS thread
LEFT JOIN ” . TABLE_PREFIX . “forum AS forum ON ( forum.forumid = thread.forumid )
WHERE NOT ISNULL(threadid) AND visible = ‘1’ AND open!=’10’
ORDER BY lastpost DESC
LIMIT 0, 10
“);
$i = 0;
while ($recent_thread = $db->fetch_array($recent_threads))
{
$i++;
if (!in_array($recent_thread[forumid], array(105,83,121,110,82,112,109,101,102,72))) {
if ($i & 1) {$class=’alt1′;} else {$class=’alt2′;}
$recent_thread[title] = unhtmlspecialchars($recent_thread[title]);
$recent_thread[lastpostdate] = vbdate(‘M jS’, $recent_thread[lastpost], 1);
$recent_thread[lastposttime] = vbdate($vbulletin->options[‘timeformat’], $recent_thread[lastpost]);
$toutput .=’

‘. $recent_thread[title].’
‘;
$toutput .=’Last Post By: ‘.$recent_thread[lastposter].’
‘;
$toutput .=’Forum: ‘.$recent_thread[forumtitle].’ | Replies: ‘.$recent_thread[replycount].’
‘;
$toutput .=’Posted: ‘.$recent_thread[lastpostdate].’ at: ‘. $recent_thread[lastposttime].’


‘;
}
}
//End Thread Counts
//Sidebar – Begin Forum Threads
$sb_threads = ‘

‘.$toutput.’

‘;
//Sidebar – End Forum Threads
echo $sb_threads;
$db->free_result($recent_threads);
$output=ob_get_contents();
ob_end_clean();
[/PHP]
Now if you want to change the color of the font find: (color: #E1E1E2″) in the above code and change it to what you need. Now if you want to change the title of the thread and hover link color you need to do this in your Stylevars.
sidebar_content_link_color
sidebar_content_link_hover_color
And change them to what you need.

 
Posted : 17/02/2020 1:01 pm
Share: