vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Latest Active Threads on Forumhome (https://vborg.vbsupport.ru/showthread.php?t=262070)

stevo_s 04-15-2011 09:19 PM

Latest Active Threads on Forumhome
 
Hi - I'm using this in VB 3.8 :
http://www.vbulletin.com/forum/showt...s-on-Forumhome


Code:

<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

Code:

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

Second, using hook external_complete and code

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

Code:

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

Quote:

Originally Posted by stevo_s (Post 2185197)
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/showt...s-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)


Code:

<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?


All times are GMT. The time now is 11:47 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02333 seconds
  • Memory Usage 1,739KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (5)bbcode_code_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete