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 12-13-2009, 07:34 PM
James Birkett James Birkett is offline
 
Join Date: Jun 2009
Posts: 633
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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?
Reply With Quote
  #2  
Old 12-13-2009, 07:55 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #3  
Old 12-14-2009, 02:22 PM
James Birkett James Birkett is offline
 
Join Date: Jun 2009
Posts: 633
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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)
Reply With Quote
  #4  
Old 12-14-2009, 03:35 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #5  
Old 12-14-2009, 03:39 PM
James Birkett James Birkett is offline
 
Join Date: Jun 2009
Posts: 633
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hey Lynne,

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

Old:
PHP Code:
eval('$HTML = "' fetch_template('shoutbox_archive') . '";'); 
Reply With Quote
  #6  
Old 12-14-2009, 03:44 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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!
Reply With Quote
  #7  
Old 12-14-2009, 03:52 PM
James Birkett James Birkett is offline
 
Join Date: Jun 2009
Posts: 633
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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!
Reply With Quote
  #8  
Old 12-14-2009, 03:56 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by James Birkett View Post
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).
Reply With Quote
  #9  
Old 12-15-2009, 11:17 AM
James Birkett James Birkett is offline
 
Join Date: Jun 2009
Posts: 633
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #10  
Old 12-15-2009, 03:20 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by James Birkett View Post
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.
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 08:58 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.04488 seconds
  • Memory Usage 2,268KB
  • 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
  • (5)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete