vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=242)
-   -   [HOW TO - vB4] Rendering templates and registering variables - a short guide (https://vborg.vbsupport.ru/showthread.php?t=228078)

SpeedyHire 07-20-2010 02:14 PM

It is related to this article? I'm asking how using what I found in this article i can do what others have clearly done since they said so in this thread. If you don't want to help me that's fine but since you helped others with there question to do with the footer I thought you might help me too silly me what was I thinking.

gopherhockey 07-26-2010 12:24 PM

oops, fixed it.

mustangcoupe69 08-29-2010 10:42 PM

I've tried following this example, but am having issues.

I am trying to get a custom template that was installed via an addon to show up in the header template.

My plugin (uses the global_start hook):
PHP Code:

$templater vB_Template::Create('vsa_paypal_donbar');
$templater->register('vsapaypal_donlist_cansee'$vsapaypal_donlist_cansee);
$templater->register('admincpdir'$admincpdir);
$templater->register('vsapp_donbar_goal'$vsapp_donbar_goal);
$templater->register('vsapp_donbar_total'$vsapp_donbar_total);
$templater->register('vsapp_donbar_done'$vsapp_donbar_done);
$templater->register('vsapp_donbar_left'$vsapp_donbar_left);
$templater->register('header'$header);
                
$vsapaypal_donbar $templater->render();
vB_Template::preRegister('header',array('vsapaypal_donbar' => $vsapaypal_donbar)); 

Then my header template starts with:
PHP Code:

{vb:raw vsapaypal_donbar

What am I missing?

vicmx 09-02-2010 05:08 AM

To add a template in another with $template_hook add this plugin:
PHP Code:

global $template_hook;
$newTemplate vB_Template::create('YOUR_CUSTOM_TEMPLATE');
$template_hook['your_var'] .= $newTemplate->render(); 

Now just print in another template:
PHP Code:

{vb:raw template_hook.your_var

For print in all pages, you can set {vb:raw template_hook.your_var} in navbar template for example.

valdet 09-07-2010 08:35 AM

Cellarius, this is an excellent article so I hope you may help me on my little issue. I read many threads and this article and I still cannot get aroudn to fix it.


In vB3 I had a simple plugin to display random banners on navbar template or parse_templates hook

Code:

$random_number = mt_rand(1, 5);

$random_banner[1] = '<img src="path/to/banner1.gif" alt="" border="0" />';
$random_banner[2] = '<img src="path/to/banner2.gif" alt="" border="0" />';
$random_banner[3] = '<img src="path/to/banner3.gif" alt="" border="0" />';
$random_banner[4] = '<img src="path/to/banner4.gif" alt="" border="0" />';
$random_banner[5] = '<img src="path/to/banner5.gif" alt="" border="0" />';

I just placed $random_banner[$random_number] anywhere in navbar and the banners would rotate on random basis.It was very simple and I would like to know how to make it work for vB4 as well.

I posted my problem in this thread too.
https://vborg.vbsupport.ru/showthread.php?t=249848

I hope you can help and thanks for your time.

Lynne 09-07-2010 01:58 PM

You need to then preregister the array $random_banner for use in the navbar. Something like:
vB_Template::preRegister('navbar', array('random_banner' => $random_banner));

valdet 09-08-2010 06:53 AM

Thank you very much Lynne,

I had to add a little bit more and actually change the plugin code to a simpler version.
Inside the plugin I had to create a third variable $new_banners and only pre-registered that variable within template and ran it through parse_templates hook

Quote:

$random_number = mt_rand(1, 5);

$random_banner[1] = '<img src="path/to/banner1.gif" alt="" border="0" />';
$random_banner[2] = '<img src="path/to/banner2.gif" alt="" border="0" />';
$random_banner[3] = '<img src="path/to/banner3.gif" alt="" border="0" />';
$random_banner[4] = '<img src="path/to/banner4.gif" alt="" border="0" />';
$random_banner[5] = '<img src="path/to/banner5.gif" alt="" border="0" />';

$new_banners = $random_banner[$random_number];

vB_Template::preRegister('navbar',array('new_banne rs' => $new_banners));
To make it work, I just dropped this code {vb:raw new_banners} on the template and now it works just as before under vB3.x.

For some (unknown) reason, {vb:raw random.banner.random_number} wasn't working as you suggested, although the arrays were set correctly.

I appreciate your help and borbole for helping me through this.

I hope other users find this little experience useful in their sites.

borbole 09-08-2010 08:46 PM

Quote:

Originally Posted by valdet (Post 2095330)
Thank you very much Lynne,

I had to add a little bit more and actually change the plugin code to a simpler version.
Inside the plugin I had to create a third variable $new_banners and only pre-registered that variable within template and ran it through parse_templates hook

To make it work, I just dropped this code {vb:raw new_banners} on the template and now it works just as before under vB3.x.

For some (unknown) reason, {vb:raw random.banner.random_number} wasn't working as you suggested, although the arrays were set correctly.

I appreciate your help and borbole for helping me through this.

I hope other users find this little experience useful in their sites.

Glad to see that you got it solved :)

owning_y0u 10-01-2010 08:14 PM

Just a small question,

i want to create a template that is showing above the header template..
do i need to register this template ? and how do i call this template above the header? its for a suite version of vB4.X

Vikingant 10-08-2010 10:09 PM

I asked this question over at the other VB forum and was directed to this article. Being completely new to all of this stuff and am still learning my way around, can someone please spell this out to me...

Quote:

Is there a way to easily move the style chooser from the footer to the navbar? I have copied the following from the footer and pasted it into various places but for some reason I only get the chooser box, but it isnt populated with the styles.

Code:

  <form action="{vb:raw vboptions.forumhome}.php" method="get" id="footer_select" class="footer_select">
 
 
  <vb:if condition="$show['quickchooser']">
  <select name="styleid" onchange="switch_id(this, 'style')">
  <optgroup label="{vb:rawphrase quick_style_chooser}">
  {vb:raw quickchooserbits}
  </optgroup>
  </select>       
  </vb:if>
 
  <vb:if condition="$show['languagechooser']">
  <select name="langid" onchange="switch_id(this, 'lang')">
  <optgroup label="{vb:rawphrase quick_language_chooser}">
  {vb:raw languagechooserbits}
  </optgroup>
  </select>
  </vb:if>
  </form>




All times are GMT. The time now is 09: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.03919 seconds
  • Memory Usage 1,765KB
  • 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
  • (2)bbcode_code_printable
  • (4)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (2)pagenav_pagelinkrel
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete