Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
  #1  
Old 07-21-2010, 05:30 PM
Darat Darat is offline
 
Join Date: Aug 2004
Posts: 329
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How to convert vB3 eval() to use vB_Template class?

This is probably a simple thing but I'm still getting my head around the changes with vB4.

We have a hack that was done for 3.x by someone who can no longer help us out and I've got most of the hack working with our test vB4 forum apart from one line and that is:

eval('$newpost[\'message\'] = "' . fetch_template('nominate', 1, 0) . '";');

The template nominate is cached earlier on in the code and the code actually works, but throws out:

Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: nominate in [path]/includes/functions.php on line 3984


How do I convert the old way of using eval() in this example to use the vB_Template class?

--------------- Added [DATE]1279738718[/DATE] at [TIME]1279738718[/TIME] ---------------

I've had a look around the site and I think it should be:

Code:
		$templater = vB_Template::create('nominate');
		$templater->register('originalposter', $originalposter);
		$templater->register('postnum', $postnum);
		$templater->register('pagetext', $pagetext);
		$nominate = $templater->render(true);
		$newpost['message'] = $nominate;
Does that look right?
Reply With Quote
  #2  
Old 07-25-2010, 08:12 PM
Hippy's Avatar
Hippy Hippy is offline
 
Join Date: Dec 2001
Location: USA, New Jersey
Posts: 2,392
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

did this work out for you ?
I'm looking to do something similar as well to

eval('$home["$mods[modid]"][\'content\'] = "' . fetch_template('adv_portal_ibproarcade') . '";');

any idea

thanks
Reply With Quote
  #3  
Old 07-26-2010, 09:04 AM
Darat Darat is offline
 
Join Date: Aug 2004
Posts: 329
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes... or perhaps I should say it seems to be working
Reply With Quote
  #4  
Old 07-26-2010, 07:07 PM
Hippy's Avatar
Hippy Hippy is offline
 
Join Date: Dec 2001
Location: USA, New Jersey
Posts: 2,392
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

cool In my case above how would I do it

--------------- Added [DATE]1280189722[/DATE] at [TIME]1280189722[/TIME] ---------------

I figured it out thank anyway
Reply With Quote
  #5  
Old 12-19-2010, 05:47 PM
SSG.D's Avatar
SSG.D SSG.D is offline
 
Join Date: Aug 2007
Posts: 60
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Got a similar need. Trying to get a older mod to function on 4.0.8 I know it's not supported but the mp3 player is awesome.

Any help from the masters here would be appreciated!
below is my headache lol

line 98 eval('$navbar = "' . fetch_template('navbar') . '";');

line 99 eval('$current .= "' . fetch_template('mp3player_popup') . '";');



Code:
Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: navbar in [path]/includes/functions.php on line 4007

Parse error: syntax error, unexpected T_STRING in /home/mysite/public_html/mp3playerindex.php(98) : eval()'d code on line 1

Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: mp3player_popup in [path]/includes/functions.php on line 4007

Parse error: syntax error, unexpected T_STRING in /home/mysite/public_html/mp3playerindex.php(99) : eval()'d code on line 2

Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: mp3player in [path]/includes/functions.php on line 4007
Total in PlayList 1: (0) Total in PlayList 2: (0)
Total in PlayList 3: (0) Total in PlayList 4: (0)
Total in PlayList 5: (0)
Reply With Quote
  #6  
Old 12-19-2010, 05:58 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Cellarius wrote a really good article that you may be interested in - [vB4] Rendering templates and registering variables - a short guide
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 07:49 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.11314 seconds
  • Memory Usage 2,198KB
  • Queries Executed 13 (?)
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
  • (2)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)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_postinfo_query
  • fetch_postinfo
  • 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