vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   How to eval template vB4 (https://vborg.vbsupport.ru/showthread.php?t=230133)

James Birkett 12-13-2009 07:34 PM

How to eval template vB4
 
PHP Code:

eval('$HTML = "' fetch_template('shoutbox_archive') . '";'); 

This is my current method of fetching a template, how do we fetch a template in vBulletin 4?

Could somebody turn that code into vb4-acceptable syntax?

EDIT: So far I have:
PHP Code:

$templater vB_Template::create('shoutbox_archive'); 

What variables am I meant to register? Every variable that's used inside the template?

Lynne 12-13-2009 07:55 PM

You register any variable you plan to use in the template - usually not also stylevars, or vboptions or session - the common ones. But, if you use them, and don't register them and they don't work, then add them in.

James Birkett 12-14-2009 02:22 PM

I register all variables except stylevars, vboptions and sessions? Does sessions include the session URL? Do I need to register the session URL?

Also, what about $vbcollapse?

The template is already created (with variables) I just need to call the template for a custom URL and register all variables, however i'm not sure which ones don't need to be registered.

Thanks in advance.

EDIT:
Old code:
PHP Code:

eval('$HTML = "' fetch_template('shoutbox_archive') . '";'); 

New code:
PHP Code:

$templater vB_Template::create('shoutbox_archive');
    
$templater->register('cansearch'$cansearch);
    
$templater->register('shouthtml'$shouthtml);
    
$templater->register('vbcollapse'$vbcollapse);
    
$templater->register('TS'$TS);
    
$templater->register('T4'$T4);
    
$templater->register('TY'$TY);
    
$templater->register('search'$search);
    
$templater->register('top_shouter_num'$top_shouter_num);
    
$templater->register('TopTen'$TopTen);
    
$templater->register('pagenav'$pagenav);
    
$HTML $templater->render(); 

Is that new code right? I.e. does it mimic the old code? (assuming all of my variables are registered correctly)

Lynne 12-14-2009 03:35 PM

It doesn't hurt to register a variable that isn't needed (like a stylevar or session). So, if you aren't sure if you need to register them or not, just put them in anyway.

James Birkett 12-14-2009 03:39 PM

Hey Lynne,

Does the above code mimic the old code, just in the new syntax?

Old:
PHP Code:

eval('$HTML = "' fetch_template('shoutbox_archive') . '";'); 


Lynne 12-14-2009 03:44 PM

Yeah, it looks fine to me. But then, I've always been one who just jumps in and tries it out - thank God for test sites!

James Birkett 12-14-2009 03:52 PM

I'm trying to output this to a ?do=archive and it won't show anything currently, thanks for your help though, i'm sure i'll figure something out!

Lynne 12-14-2009 03:56 PM

Quote:

Originally Posted by James Birkett (Post 1930565)
I'm trying to output this to a ?do=archive and it won't show anything currently, thanks for your help though, i'm sure i'll figure something out!

And is $HTML registered to be used in whatever template used in do=archive? (I have no idea where that page is).

James Birkett 12-15-2009 11:17 AM

do=archive is an archive for my shoutbox.

So if I assign the template to variable $HTML, that variable has to be registered also?

I'll fix that little error.

Lynne 12-15-2009 03:20 PM

Quote:

Originally Posted by James Birkett (Post 1931058)
do=archive is an archive for my shoutbox.

So if I assign the template to variable $HTML, that variable has to be registered also?

I'll fix that little error.

Yep, all variables must be registered for use in a template now.


All times are GMT. The time now is 12:09 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.01138 seconds
  • Memory Usage 1,746KB
  • 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
  • (5)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (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