vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Displaying a template within the header template? (https://vborg.vbsupport.ru/showthread.php?t=229282)

saajjj 12-01-2009 08:28 PM

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,

Lynne 12-01-2009 09:00 PM

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.

saajjj 12-01-2009 09:39 PM

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.

Lynne 12-01-2009 09:56 PM

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?

saajjj 12-02-2009 07:41 AM

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

Thanks again.


All times are GMT. The time now is 11:10 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.01018 seconds
  • Memory Usage 1,740KB
  • 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
  • (6)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)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