Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
  #1  
Old 05-26-2010, 03:10 PM
deadbydawn's Avatar
deadbydawn deadbydawn is offline
 
Join Date: May 2010
Posts: 14
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Insert template within template

Is it possible for me to call a template from inside another template?

eg, I'd like to throw all of my custom stuff into a brand new template, and then open the SHOWTHREAD template and manually place it in there without junking it up too much.

Is it only possible to do this via plugin/template_hook calls, or is there a manual method i'm missing?
Reply With Quote
  #2  
Old 05-27-2010, 10:59 AM
consolegaming consolegaming is offline
 
Join Date: Jan 2007
Posts: 168
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes it's possible, I do this with my header and footer and then just have one liners in the two templates. First of all you need to create a plugin. The parse_templates hook works well for me.

PHP Code:
$templater vB_Template::create('custom_template'); 
$templates $templater->render(); 
vB_Template::preRegister('footer', array('custom_template' => $templates)); 
And then inside the footer template (in the example above as that's where I registered the custom template) you just do:

Code:
{vb:raw custom_template}
Basically you need to register your custom template as a variable which you can then use in the template you just registered it for.
Reply With Quote
  #3  
Old 05-27-2010, 03:59 PM
deadbydawn's Avatar
deadbydawn deadbydawn is offline
 
Join Date: May 2010
Posts: 14
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Fantastic, thank you so much!

I'm playing with it a bit now and i'm getting it to insert the template as I would expect, but there's one thing I'm not certain about.. Because I am doing something with the SHOWTHREAD template, I am making use of some variables such as {vb:raw threadid} and {vb:raw pagenumber}.

These are not being called properly when using the plugin method of inserting the template.. is that simply a byproduct of this (meaning I should likely continue to edit the template manually), or is there a method that would make it work?

I thought perhaps changing the hook call could allow it to have the necessary info first, but I don't think that's it. Maybe there's a way for me to tell it to get that info from showthread?

Thanks again
Reply With Quote
  #4  
Old 05-28-2010, 12:20 AM
consolegaming consolegaming is offline
 
Join Date: Jan 2007
Posts: 168
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm guessing your problem is that you need to register these variables for use in your custom template.

Just after the first line (before the render line) try this in your plugin:
PHP Code:
$templater->register('threadid'$threadid); 
That's telling it to register the threadid variable to be used inside your custom template. It's a bit of a pain in the backside having to register already existing variables I know but that should be what you need. I know when I first looked at the system I just expected these variables to work straight away lol.
Reply With Quote
  #5  
Old 05-28-2010, 04:47 PM
deadbydawn's Avatar
deadbydawn deadbydawn is offline
 
Join Date: May 2010
Posts: 14
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That was exactly it. You are awesome, thank you!
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 11:12 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.03688 seconds
  • Memory Usage 2,193KB
  • 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
  • (2)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