vb.org Archive

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

Michael.A 05-02-2012 12:45 AM

Rendering a template in header
 
Hook Location:
global_start

PHP Code:

if ($vbulletin->options['teck_brb_enable']
    and 
is_member_of($vbulletin->userinfoexplode(',',$vbulletin->options['teck_brb_groups'])))

$teck_brb_temp "teck brb away";

$teck_brb = array();
$teck_brb['url'] = $vbulletin->options['teck_brb_url'];
$teck_brb['s_i_path'] = $vbulletin->options['teck_brb_s_i_path'];
$teck_brb['b_i_path'] = $vbulletin->options['teck_brb_b_i_path']; 

$templater vB_Template::create('teck_brb_temp'); 
    
$templater->register('teck_brb_temp'$teck_brb_temp);
    
$templater->register('teck_brb'$teck_brb); 
    
$templatevalues['teck_brb_temp'] = $templater->render();
    
vB_Template::preRegister('header',array('teck_brb_temp' => $teck_brb_temp));




trying to have Template $teck_brb_temp to show in the header!!

kh99 05-02-2012 09:31 AM

I think the next to the last line should be:

PHP Code:

    $teck_brb_temp $templater->render(); 


Michael.A 05-02-2012 11:02 AM

do u mean with out a array?
well this make it show up all the way on top of the header template?

i try it out thanks..

kh99 05-02-2012 11:13 AM

You don't need the array. I think maybe you were confusing two different ways to preRegsiter a variable: you can create an array then use it in the preRegister call, or else you can just use array() directly in the function call.

You will also need to edit your header template and insert {vb:raw teck_brb_temp} where you want it to appear. Another way to get it to appear in your header would be to use a template hook that's already in the header (if there are any - I haven't checked), in which case you'd assign the result of render() to the template hook instead of using preRegister().

Michael.A 05-02-2012 11:43 AM

how about something like that how can i use that for my need:

PHP Code:

$output str_replace('<div class="ad_global_header">',
$templater->render().'<div class="ad_global_header">'$output); 

i want it on top of the header template and i also want it easy for plp to use!!

kh99 05-02-2012 11:56 AM

OK, so you're saying you want a plugin that will insert it automatically, so you can release a product and not have to have any template editing instructions? OK, you could try this: use hook process_templates_complete and code like (just showingthe last few lines):

Code:

$templater = vB_Template::create('teck_brb_temp');
    $templater->register('teck_brb_temp', $teck_brb_temp);
    $templater->register('teck_brb', $teck_brb);
$header = $templater->render() . $header;


But I think that hook was recently added, in vb4.1.10 or so, so it might not work in older versions. For versions before that you might need to do a replacement on $vbulletin->templatecache['header'] which is a little complicated. Here's a post showing an example of one way to do it:

https://vborg.vbsupport.ru/showpost....&postcount=211

Michael.A 05-02-2012 12:27 PM

thanks man it look like it works for me on:

Hook Location:
global_start

PHP Code:

$header $templater->render() . $header

do i have to use it on process_templates_complete?

--------------- Added [DATE]1335978843[/DATE] at [TIME]1335978843[/TIME] ---------------

Special Thanks to you for making this..
https://vborg.vbsupport.ru/showthrea...42#post2325542


All times are GMT. The time now is 01:46 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.01116 seconds
  • Memory Usage 1,736KB
  • 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
  • (4)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)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