vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   Timestamp in vBulletin header (https://vborg.vbsupport.ru/showthread.php?t=311798)

dveaner51 05-30-2014 02:27 PM

Timestamp in vBulletin header
 
I need to pass a timestamp as a variable to a URL in an iFrame. In PHP it would be this:

PHP Code:

$tm time();
echo 
"<iframe src=\"http://www.SiteIamFraming.com/gim/?a=$tm\" frameBorder=\"0\" width=\"350\" height=\"180\" scrolling=\"no\" id=\"iframeID\" style=\"display:block;\"> </iframe>"

How can I do this in the header file of a vBulletin template?

Thanks

Lynne 05-30-2014 04:49 PM

I believe TIMENOW is available for use, so try just adding this to the template:

HTML Code:

<iframe src="http://www.SiteIamFraming.com/gim/?a={vb:raw timenow}" frameBorder="0" width="350" height="180" scrolling="no" id="iframeID" style=\"display:block;\"> </iframe>

dveaner51 05-30-2014 05:15 PM

That's returning nothing -- is there a way to make it print to the screen in the template code as "echo" does in PHP?

BTW I should have mentioned I am working in vBulletin 4.

Lynne 05-30-2014 06:52 PM

You may need to write a plugin then to create a variable that has the time. Probably use one of the global* hook locations.

No, you cannot use any php in a template.

dveaner51 05-30-2014 07:24 PM

Bummer. I don't see why this has to be so hard.

Thanks for your help.

Lynne 05-30-2014 10:49 PM

It shouldn't be that hard. Did you try just adding a plugin to create the variable (you will need to preregister the variable for use in what template you are using it in also).

dveaner51 05-31-2014 01:42 PM

Lynne,

I've been looking at other plugins as examples and created a simple plugin and activated it. I think I have most of it, but I am confused about where the preregistering line goes, and not really sure about which hook location to use. So two questions:

1. Should the hook location be global_start or something else?

2. My variable is called includeticker. I am confused about where to put the preregister line (which I think is right (below). Should I be using "header"? Our forum has various templates. Should the actual name of the template be where "header" is in my line? Like "Blue Template" if that's the name?

PHP Code:

vB_Template::preRegister('header',array('includeticker ' => $includeticker)); 


Once those are figured out all I have to do is insert this where I want it to appear in the header, right?

PHP Code:

{vb:raw includeticker

Thanks again,

Dan

Lynne 05-31-2014 04:07 PM

1. You can try global_start. That hook is supposed to be deprecated, but it doesn't seem to be going away at all. You can also try global_bootstrap_complete which is the one I have used before to preregister a variable for the header template.

2. If you want to use the variable in another template, then just replace "header" with the name of the other template. If you need to register it for use for several templates, then just have several preregister lines. You can just put that line at the bottom of your plugin.

dveaner51 05-31-2014 05:21 PM

Success!!!

I switched the hook location to template_render_output and that did it.

Lynne, thanks for all your help. I never would have gotten this to work without your guidance.

Dan


All times are GMT. The time now is 04:43 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.01060 seconds
  • Memory Usage 1,729KB
  • 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_html_printable
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)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