Examples of what you can do with the plugin are listed below.
Add the code to the hook "ajax_drop_menu_start"
Example 1
You can have the latest 5 threads from a specific forum
PHP Code:
$getthreads = $db->query_read("SELECT * FROM " . TABLE_PREFIX . "thread WHERE forumid='5' ORDER BY threadid DESC LIMIT 5");
while($lt = $db->fetch_array($getthreads))
{
$latestthreads .= "Title: <a href='showthread.php?t=$lt[threadid]'>".$lt['title']."</a> | Posted By: <a href='member.php?u=$lt[postuserid]'>".$lt['lastposter']."</a><br />";
}
$cm['text'] = str_replace("[latestthreads]", $latestthreads, $cm['text']);
When you create a new message you can now use
[latestthreads] to populate the lastest 5 threads posted in forumid 5.
Example 2
This will display the top five users with the highest post count
PHP Code:
$gettopusers = $db->query_read("SELECT * FROM " . TABLE_PREFIX . "user ORDER BY posts DESC LIMIT 5");
while($gtu = $db->fetch_array($gettopusers))
{
$topusers.= "<a href='member.php?u=$gtu[userid]'>".$gtu['username']."</a>: $gtu[posts]<br />";
}
$cm['text'] = str_replace("[topusers]", $topusers, $cm['text']);
When you create a new message you can now use
[topusers] to populate the results
Example 3
This will display the latest 5 threads in every forum the user can access
PHP Code:
$count = 0;
$getposts = $db->query_read("
SELECT DISTINCT thread.title AS title, thread.threadid AS threadid, forum.forumid AS forumid
FROM " . TABLE_PREFIX . "post AS post
LEFT JOIN " . TABLE_PREFIX . "thread AS thread
ON post.threadid = thread.threadid
LEFT JOIN " . TABLE_PREFIX . "forum AS forum
ON thread.forumid = forum.forumid
ORDER BY postid DESC");
while($post = $db->fetch_array($getposts))
{
$forumperms = fetch_permissions($post['forumid']);
if (($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) OR ($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewthreads']))
{
if($count <= 5)
{
$latestthreads2 .= "<b>Title</b>: <a href='showthread.php?t=$post[threadid]'>".$post['title']."</a><br />";
}
$count++;
}
}
$cm['text'] = str_replace("[latestthreads_2]", $latestthreads2, $cm['text']);
Use
[latestthreads_2] to populate the results