Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
  #1  
Old 12-01-2009, 08:28 PM
saajjj saajjj is offline
 
Join Date: Nov 2009
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Displaying a template within the header template?

Hello,
I've made a very simple template (called tmplt_simpleWord) which is just a single word: test
I want to display this template in the header.

In the header template, I've got:
Code:
{vb:raw show_simpleWord}
The plug-in is:
PHP Code:
$templater vB_Template::create('tmplt_simpleWord');
$templateValues['show_simpleWord'] = $templater->render();
vB_Template::preRegister('header'$templateValues); 
I've tried this with the following hooks but none of them does anything to the header:
global_start
process_templates_complete

I've been successful in inserting the same template into FORUMHOME by switching the last line of the plugin from:
PHP Code:
vB_Template::preRegister('header'$templateValues); 
to
PHP Code:
vB_Template::preRegister('FORUMHOME'$templateValues); 
, setting the hook to forumhome_start and adding the same template code to the FORUMHOME template.

What am I doing wrong in trying to insert the template into the header?
Any help appreciated.

Cheers,
Reply With Quote
  #2  
Old 12-01-2009, 09:00 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I was just replying to someone wanting to do something similar in the footer template. The header template, just like the footer and headinclude template, gets rendered early on (check class_bootstrap.php). You will have to pick a hook location that is rendered before the template is rendered, or rerender it.
Reply With Quote
  #3  
Old 12-01-2009, 09:39 PM
saajjj saajjj is offline
 
Join Date: Nov 2009
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for that Lynne, I tried using global_start which I thought would precede everything else but no luck. However (as Seven Skins has said in the thread you mentioned) I too can output values directly from the plug-in, but I can't seem to insert a template.

So where as this works:

Hook: global_start

PHP Code:
$simpleWord "word";
vB_Template::preRegister('header',array('show_simpleWord' => $simpleWord)); 
This doesn't:

Hook: global_start

PHP Code:
$templater vB_Template::create('tmplt_simpleWord');
$templateValues['show_simpleWord'] = $templater->render();
vB_Template::preRegister('header'$templateValues); 
Please consider this thread closed as I will be following Seven Skins' thread for a solution instead.
Reply With Quote
  #4  
Old 12-01-2009, 09:56 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try something more like this:
PHP Code:
$templater vB_Template::create('tmplt_simpleWord'); 
$templateValues $templater->render(); 
vB_Template::preRegister('header', array('templateValues' => $templateValues)); 
And then use {vb:raw templateValues} in the template.

Did you look in the file I told you to? You'll see the hook location parse_templates right above where the templates are rendered. Why not try that hook location?
Reply With Quote
  #5  
Old 12-02-2009, 07:41 AM
saajjj saajjj is offline
 
Join Date: Nov 2009
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Gah, I totally missed that sorry. And thanks - changing the hook to parse_templates with the original code works perfectly

Thanks again.
Reply With Quote
Reply

Thread Tools
Display Modes

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 05:36 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.04111 seconds
  • Memory Usage 2,206KB
  • 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_code
  • (6)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)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
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete