Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 05-30-2014, 02:27 PM
dveaner51 dveaner51 is offline
 
Join Date: Mar 2014
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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
Reply With Quote
  #2  
Old 05-30-2014, 04:49 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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>
Reply With Quote
  #3  
Old 05-30-2014, 05:15 PM
dveaner51 dveaner51 is offline
 
Join Date: Mar 2014
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #4  
Old 05-30-2014, 06:52 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #5  
Old 05-30-2014, 07:24 PM
dveaner51 dveaner51 is offline
 
Join Date: Mar 2014
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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

Thanks for your help.
Reply With Quote
  #6  
Old 05-30-2014, 10:49 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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).
Reply With Quote
  #7  
Old 05-31-2014, 01:42 PM
dveaner51 dveaner51 is offline
 
Join Date: Mar 2014
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #8  
Old 05-31-2014, 04:07 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #9  
Old 05-31-2014, 05:21 PM
dveaner51 dveaner51 is offline
 
Join Date: Mar 2014
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
Благодарность от:
Lynne
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:59 PM.


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.04109 seconds
  • Memory Usage 2,244KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_html
  • (3)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (1)post_thanks_box_bit
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete