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 convert vB3 eval() to use vB_Template class? (https://vborg.vbsupport.ru/showthread.php?t=247017)

Darat 07-21-2010 05:30 PM

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?

Hippy 07-25-2010 08:12 PM

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

Darat 07-26-2010 09:04 AM

Yes... or perhaps I should say it seems to be working :)

Hippy 07-26-2010 07:07 PM

cool In my case above how would I do it

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

I figured it out thank anyway

SSG.D 12-19-2010 05:47 PM

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)


Lynne 12-19-2010 05:58 PM

Cellarius wrote a really good article that you may be interested in - [vB4] Rendering templates and registering variables - a short guide


All times are GMT. The time now is 07:06 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.01631 seconds
  • Memory Usage 1,724KB
  • 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
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete