vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Using existing variables in different templates (https://vborg.vbsupport.ru/showthread.php?t=313769)

Thr33 08-18-2014 02:13 AM

Using existing variables in different templates
 
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
Code:

{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)
PHP Code:

$lastvisitdate vbdate($vbulletin->options['dateformat'], $vbulletin->userinfo['lastvisit'], 1);
$lastvisittime vbdate($vbulletin->options['timeformat'], $vbulletin->userinfo['lastvisit']);
vB_Template::preRegister('FORUMHOME',array('lastvisittime' => $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


All times are GMT. The time now is 08:32 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.01022 seconds
  • Memory Usage 1,723KB
  • 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
  • (1)bbcode_code_printable
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete