PDA

View Full Version : Fetch Template


Slayerz
09-01-2011, 06:54 PM
I saw a few threads about it, but they were vague and I couldn't get too deep of a grasp for the basis of it.

I was wondering how to change raw php, using templates.

For instances, I got the program to work and it shows in admincp, but to view it on forum errors occur.

So I checked it out and found out that it's mostly fetch template coding.

I was wondering if there is a simple method to easily change the fetch templates into vb_template class.

As if to take main standards of the fetch and just use it in a template of the vb_template class for it to read and work.

kh99
09-01-2011, 07:00 PM
I don't understand. Do you mean you want to convert vb3 type "fetch and eval" template code to vb4? Or do you want to change an adminCP "just print out the html" page to work in with templates?

Slayerz
09-01-2011, 07:06 PM
I wanted to convert vb3 type "fetch and eval" into vb4

kh99
09-01-2011, 07:12 PM
Here's an article on that. https://vborg.vbsupport.ru/showthread.php?t=228078

You really just have to create the template object and call render(), but the big difference is that you have to register all the variables used in the template, where you didn't have to do that at all in vb3.

Also the template syntax changed. That's described in the manual: https://www.vbulletin.com/docs/html/main/templates_intro

Basically, <if> and <else> are now <vb:if> and <vb:else>, and where you had $varname before you'd now have {vb:raw varname} (but not in condition="", those would stay the same).

Slayerz
09-01-2011, 07:25 PM
I saw that, but wasn't 100% sure on what'd I do for this.

eval('$templater = vB_Template::create('inferno_header');
$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
}

How would that be changed?

kh99
09-01-2011, 08:43 PM
To be honest I don't know what to make of that. Are you trying to add a template called 'inferno_header' to your navbar? Then you'd want something like this:

$templater = vB_Template::create('inferno_header');
$inferno_header = $templater->render();
vB_Template::preRegister('navbar', array('inferno_header' => $inferno_header));
and then in the navbar template:

{vb:raw inferno_header}

Slayerz
09-01-2011, 08:47 PM
That's what I'm assuming.

I'm taking a failed modification and rebuilding it.