View Full Version : Getting foruminfo and bbuserinfo into the header template?
Jaxel
04-14-2010, 08:13 PM
So I have my random header mod:
https://vborg.vbsupport.ru/showthread.php?t=212351
However, it doesn't work in VB4 because of the new template registration system. It looks like you can't call any of the foruminfo or bbuserinfo variables in the header. Is there any way I would be able to pull this info into the header, without having to do some php file editing? Maybe with some hooks?
Lynne
04-15-2010, 01:24 AM
Have you looked at the header template? bbuserinfo is used several times in there, so I'm not sure why you would say you can't use it. You will probably have to preregister a forumid variable to use - see this article on that: [vB4] Rendering templates and registering variables - a short guide (https://vborg.vbsupport.ru/showthread.php?t=228078)
Jaxel
04-15-2010, 02:04 AM
I got bbuserinfo working, but I can't get foruminfo working.
Is there any way I would be able to pull this info into the header, without having to do some php file editing? Maybe with some hooks?
Lynne
04-15-2010, 03:18 AM
Did you read that article? Yes, you may use a hook to preregister the variable.
Jaxel
04-15-2010, 01:53 PM
Of course I read the article, I read it weeks ago. It doesn't actually help me at this point as it doesn't answer my question. The article tells me how to render variables and templates in my own custom mods. It doesn't tell me how to use it in plugins.
What hook should I be using? What code should be in the plugin?
Lynne
04-15-2010, 02:09 PM
No article is going to tell you what hook location to use. Go into debug mode and look at the list on the bottom of the page and use one of those. Better yet, find the area in the code you are need to target (in this case, your target is prior to the rendering of the header template, so find where it is rendered) and look for a hook that is rendered before that. And that article gives you an example of the code to preregister your variable right near the end:
Save into an array and preregister to use in an existing/stock template
$templater = vB_Template::create('mytemplate');
$templater->register('my_var', $my_var);
$templater->register('my_array', $my_array);
$templatevalues['my_insertvar'] = $templater->render();
vB_Template::preRegister('FORUMHOME', $templatevalues);
Jaxel
04-15-2010, 05:15 PM
Yeah, but that code just doesn't work for me... I tried the forumdisplay_complete hook (I know that $forumid exists at that location), and couldn't get it working...
$templater = vB_Template::create('mytemplate');
$templater->register('forumid', $forumid);
$templatevalues['forum'] = $templater->render();
vB_Template::preRegister('header', $templatevalues);
{vb:var forum.forumid}
What is "mytemplate"? Basically, what it seems like, is that I need to find a hook AFTER $forumid has been set, but before the header template has been constructed. However, if $forumid isn't set before the header template is constructed, then this whole process is pointless. Looking through forumdisplay.php, I can't find where the header is being constructed, so who knows where the hell this needs to be. If the header is the first thing constructed, then it looks like I am shit out of luck.
--------------- Added 1271356345 at 1271356345 ---------------
Well i just tried the following at forumdisplay_start:
$templater = vB_Template::create('mytemplate');
$templater->register('forumid', $vbulletin->GPC['forumid']);
$templatevalues['forum'] = $templater->render();
vB_Template::preRegister('header', $templatevalues);
{vb:var forum.foruminfo.forumid}
It seems like its already too late to register anything in the header, even at the start of forumdisplay. So basically as I said before, its IMPOSSIBLE to call in forum information in the header in VB4.
--------------- Added 1271356919 at 1271356919 ---------------
Honestly, looking at this whole methodology, it seems a bit messed up. It's not really a "solution", but more of a "workaround". You are creating a false template "mytemplate", which is used exactly NOWHERE in order to pass a small array. Its inefficient programming, a complete waste of resources and a demonstration of how things shouldn't be done. Its like this whole system was designed by game programmers.
--------------- Added 1271357244 at 1271357244 ---------------
Okay... it looks like my question is answered in the COMMENTS to the article, rather than the article itself...
$forum= array('forumid' => $vbulletin->GPC['forumid']);
vB_Template::preRegister('header',array('forum' => $forum));
forumdisplay_start
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.