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)

psypher 01-18-2010 08:13 PM

nvm figured it out

mokujin 01-19-2010 08:45 PM

I have read all posts and dont know how to call 3 templates in one page.

I have this code:

PHP Code:

if ($_REQUEST['do'] == 'page1')
{
  
$templater vB_Template::create('temp_page1');
  
    
/* 
    how can I  fetch another template here? 
    in vb3: eval('$pagebit .= "' . fetch_template('page_bit') . '";');     ???
    
    */

  
$mypage .= $templater->render();
}
 
// called 2 templates 'temp_page1' and 'temp_home' OK, and what  'page_bit'?
    
$templater vB_Template::create('temp_home');
$templater->register_page_templates();
$templater->register('mypage'$mypage);
$templater->register('navbar'$navbar);
$templater->register('pagetitle'$pagetitle);
print_output($templater->render()); 


derfelix 01-21-2010 04:04 AM

I would fetch it before...

PHP Code:

if ($_REQUEST['do'] == 'page1')
{

  
$templater vB_Template::create('page_bit');
 
  
$mypage_bit .= $templater->render();

  
$templater vB_Template::create('temp_page1');
  
$templater->register('mypage_bit'$mypage_bit);
  
$mypage $templater->render();
}

    
$templater vB_Template::create('temp_home');
$templater->register_page_templates();
$templater->register('mypage'$mypage);
$templater->register('navbar'$navbar);
$templater->register('pagetitle'$pagetitle);
print_output($templater->render()); 


F.

ChopSuey 01-22-2010 10:29 PM

Thanks for this, hopefully i'll be able to know what to do.

TheSupportForum 01-25-2010 05:56 AM

does anyone know how i can insert this into a template using plugin manager
to be placed in header

Code:


function bb2_insert_head() {
 global $bb2_javascript;
 echo $bb2_javascript;
}


OcR Envy 01-25-2010 02:30 PM

n/m I figured I was missing $templater->render();

moonray 02-09-2010 04:21 PM

I am not much of a coder at all, and hence need your help big time.

I want to call a simple php file to be placed just under the navbar. So, I created a plugin:
Product: vBulletin
Title: Insert Simple PHP
Execution order: 5 (it was default)
Hook Location: global_start
PHP code:
Code:

ob_start();
include('simple.php');
$insert_simple_php = ob_get_contents();
ob_end_clean();

Plugin is active: Yes

Now, I went to the NAVBAR template and inserted
Code:

{vb:raw insert_simple_php}
just under the code
Code:

{vb:raw ad_location.global_below_navbar}
Questions:
* Where does the 'register/pre-register' come?
* What is the exact change I need to make here?

Thanks for your help!

FatalBreeze 02-17-2010 04:29 PM

Great article!
but i have a problem.
I have a template which i want to show inside another template, and it seems to work with every template except for the header.
This is the plugin i used:
PHP Code:

$templateH vB_Template::create('TopPanel')->render();
vB_Template::preRegister('header', array('TopPanel' => $templateH));
$TL vB_Template::create('TopPanel')->render();
vB_Template::preRegister('vbcms_page', array('TopPanel' => $TL));
$TL2 vB_Template::create('BarH')->render();
vB_Template::preRegister('vbcms_page', array('BarT' => $TL2)); 

the hook location is: process_templates_complete.
of course i have a template called TopPanel which i created, and it works great in vbcms_page for example but not in header.
Do you have an idea why is that?

Thanks in advance.

cellarius 02-18-2010 05:45 AM

As the name suggests, the hook you use is called when vB-internal template processing is already completed. No use in preregistering templates then anymore. Since that hook did not exist in 4.0.1 as far as I can see, you're using 4.0.2. Another hook that got added in 4.02 is template_register_var, and that would be the right one to use.

cellarius 02-23-2010 07:19 AM

Quote:

Originally Posted by moonray (Post 1978401)
I am not much of a coder at all, and hence need your help big time.

I want to call a simple php file to be placed just under the navbar. So, I created a plugin:
Product: vBulletin
Title: Insert Simple PHP
Execution order: 5 (it was default)
Hook Location: global_start
PHP code:
Code:

ob_start();
include('simple.php');
$insert_simple_php = ob_get_contents();
ob_end_clean();

Plugin is active: Yes

Now, I went to the NAVBAR template and inserted
Code:

{vb:raw insert_simple_php}
just under the code
Code:

{vb:raw ad_location.global_below_navbar}
Questions:
* Where does the 'register/pre-register' come?
* What is the exact change I need to make here?

Thanks for your help!

Try this in the plugin:
PHP Code:

ob_start();
include(
'simple.php');
$templatevalues['insert_simple_php'] = ob_get_contents();
ob_end_clean();
vB_Template::preRegister('navbar'$templatevalues); 



All times are GMT. The time now is 06:13 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.01495 seconds
  • Memory Usage 1,764KB
  • 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
  • (7)bbcode_code_printable
  • (4)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)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