PDA

View Full Version : Using existing variables in different templates


Thr33
08-18-2014, 02:13 AM
Ive been looking through manuals and i just cant get my head around using pre-existing raw variables in different templates. Im rather new to the coding arena of vBulletin and this issue keeps blocking me from modifying templates.

Example:
In the header template we have
{vb:raw pmbox.lastvisitdate}, {vb:raw pmbox.lastvisittime}

Now if i wanted to put this data in FORUMHOME template instead i cant seem to do it, even if i change the raw to a var, it simply wont display anything. Ive heard a lot about declaring variables but with the root "pmbox." i assumed it would still display as its makes it globally accessible.

Any help?

Scanu
08-18-2014, 08:38 AM
Even the variables you see in vbulletin templates aren't global you have to register them again if you want to use them in another template
There are only a few variables and costants that are availavle in every template
However the last visit and activity code is very easy you could make a new plugin

Plugin hook: forumhome_start (should work)

$lastvisitdate = vbdate($vbulletin->options['dateformat'], $vbulletin->userinfo['lastvisit'], 1);
$lastvisittime = vbdate($vbulletin->options['timeformat'], $vbulletin->userinfo['lastvisit']);
vB_Template::preRegister('FORUMHOME',array('lastvi sittime' => $lastvisittime, 'lastvisitdate' => $lastvisitdate));

And then you'll be able to use {vb:raw lastvisittime}, {vb:raw lastvisitdate}
I didn't test it so I'm not sure it will work but you can play this plugin and see if you can get it working by yourself, if you can't feel free to ask further help :)

Thr33
08-18-2014, 09:36 AM
Thank you!! I'll be trying this when i get back to the templates. This also helps me understand more in registering variables.

ozzy47
08-18-2014, 09:44 AM
cellarius wrote a good article on registering variables here, https://vborg.vbsupport.ru/showthread.php?t=228078