PDA

View Full Version : Latest Active Threads on Forumhome


stevo_s
04-15-2011, 09:19 PM
Hi - I'm using this in VB 3.8 :
http://www.vbulletin.com/forum/showthread.php/158887-HowTo-Display-Latest-Active-Threads-on-Forumhome


<script language="" type="text/javascript">
<!--
for (x = 0; x < 5; x++)
{
document.writeln("<img class=\"inlineimg\" src=\"$stylevar[imgdir_button]/lastpost.gif\" alt=\"\" border=\"0\" /> <a href=\"showthread.php?t="+threads[x].threadid+"\">"+threads[x].title+"</a> <span class=\"time\">($vbphrase[posted_by]: "+threads[x].poster+")</span><br />");
}
//-->
</script>

which comes out as

Thread title1 (Posted By: username1)
Thread title2 (Posted By: username2)
Thread title3 (Posted By: username3)


and it works fine.
but any idea how I would get it to display the forum name as well and have the forumname linkable as well?:

Thread title3 (Posted By: username3) in Forum4

kh99
04-15-2011, 11:29 PM
You can do it, but you need to create two plugins.

First, using hook external_query and code

$hook_query_fields .= " , forum.title AS forumname ";


Second, using hook external_complete and code

if ($vbulletin->GPC['type'] == 'JS')
{ // javascript output
$output .= "
function forum(forumname, forumid)
{
this.forumname = forumname;
this.forumid = forumid;
}
";
$output .= "var forums = new Array(" . sizeof ($threadcache) . ");\r\n";
if (!empty($threadcache))
{
foreach ($threadcache AS $threadnum => $thread)
{
$thread['forumname'] = addslashes_js(htmlspecialchars_uni($thread['forumname']));
$output .= "\tforums[$threadnum] = new forum('$thread[forumname]', $thread[forumid]);\r\n";
}
}
}


Then you also need to edit the FORUMHOME template, find the code you added, and replace the line that starts with document.write with

document.writeln("<img class=\"inlineimg\" src=\"$stylevar[imgdir_button]/lastpost.gif\" alt=\"\" border=\"0\" /> <a href=\"showthread.php?t="+threads[x].threadid+"\">"+threads[x].title+"</a> <span class=\"time\">($vbphrase[posted_by]: "+threads[x].poster+")</span> in <a href=\"forumdisplay.php?f="+forums[x].forumid+"\">"+forums[x].forumname+"</a><br />");

stevo_s
04-16-2011, 08:23 AM
Do I need to create plugins if it is live and working fine as is?

kh99
04-16-2011, 11:29 AM
Do I need to create plugins if it is live and working fine as is?

As far as I know, yes, because the forum name and id are not available the way it is.

If someone else has an alternative, please post it.

stevo_s
04-16-2011, 12:14 PM
It wont break anything long term though will it?
like I say it is working fine as is on the forumhome.

kh99
04-16-2011, 12:28 PM
Well, it's true whenever you add a plugin it's possible that it will cause a problem someday when you upgrade, so you have to weigh that against how much you want the mod. In this case I don't think there's too much risk.

I'm more a programmer and I'm not familiar with all the mods that are available, so if you feel better installing a product, maybe there's something else out there that will do what you want.

stevo_s
04-16-2011, 01:13 PM
Sorry what I mean is it safe to jsut add the code from here:
http://www.vbulletin.com/forum/showthread.php/158887-HowTo-Display-Latest-Active-Threads-on-Forumhome

rather than needing to make a plugin first as it works fine.

kh99
04-16-2011, 01:21 PM
Oh...yeah, that only requires template edits so you don't need any plugins for that.

stevo_s
04-16-2011, 01:35 PM
cool- any idea how I'd get

Thread title3 (Posted By: username3) in Forum4

rather than just

Thread title3 (Posted By: username3)


<script language="" type="text/javascript">
<!--
for (x = 0; x < 5; x++)
{
document.writeln("<img class=\"inlineimg\" src=\"$stylevar[imgdir_button]/lastpost.gif\" alt=\"\" border=\"0\" /> <a href=\"showthread.php?t="+threads[x].threadid+"\">"+threads[x].title+"</a> <span class=\"time\">($vbphrase[posted_by]: "+threads[x].poster+")</span><br />");
}
//-->
</script>

kh99
04-16-2011, 01:45 PM
Sorry, you lost me now. Like I said, you can't do it without plugins.

I'm out - anyone else want to take a shot at this?

stevo_s
04-16-2011, 04:00 PM
you can't do it without plugins.

it works without having to create a plugin.

All I need is to add the name of the forum the thread is in at the end.

What I have is :
Thread title1 (Posted By: username1)

like to have:
Thread title1 (Posted By: username1) in Forumname

I just don't know the proper syntax for the name of a forum to add in here-

document.writeln("<img class=\"inlineimg\" src=\"$stylevar[imgdir_button]/lastpost.gif\" alt=\"\" border=\"0\" /> <a href=\"showthread.php?t="+threads[x].threadid+"\">"+threads[x].title+"</a> <span class=\"time\">($vbphrase[posted_by]: "+threads[x].poster+")</span><br />");