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

Reply
 
Thread Tools Display Modes
  #1  
Old 05-02-2012, 12:45 AM
Michael.A's Avatar
Michael.A Michael.A is offline
 
Join Date: Dec 2008
Location: L.A
Posts: 449
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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!!
Reply With Quote
Благодарность от:
Craigr
  #2  
Old 05-02-2012, 09:31 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think the next to the last line should be:

PHP Code:
    $teck_brb_temp $templater->render(); 
Reply With Quote
  #3  
Old 05-02-2012, 11:02 AM
Michael.A's Avatar
Michael.A Michael.A is offline
 
Join Date: Dec 2008
Location: L.A
Posts: 449
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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..
Reply With Quote
  #4  
Old 05-02-2012, 11:13 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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().
Reply With Quote
  #5  
Old 05-02-2012, 11:43 AM
Michael.A's Avatar
Michael.A Michael.A is offline
 
Join Date: Dec 2008
Location: L.A
Posts: 449
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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!!
Reply With Quote
  #6  
Old 05-02-2012, 11:56 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
Благодарность от:
Michael.A
  #7  
Old 05-02-2012, 12:27 PM
Michael.A's Avatar
Michael.A Michael.A is offline
 
Join Date: Dec 2008
Location: L.A
Posts: 449
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
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:02 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.07230 seconds
  • Memory Usage 2,235KB
  • 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
  • (4)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (2)post_thanks_box_bit
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)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
  • 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
  • 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