PDA

View Full Version : Template <if> tag


zethon
08-16-2009, 09:16 PM
I have a personal project going on and I'm trying to develop a template system similar to the one vBulletin uses.

One thing has me stumped. I want to use the <if> tag in my templates, but they never get parsed. I looked in the vb code for some help, but I can't see anything that much different from vb is doing and what I'm doing to cause this.

What is it in the vb that 'allows' the parsing to the <if> tag?

The code I'm using to import that template and print it looks like:


$file = implode("",file($config['Path']['templates']."/postbit.html"));
eval('$file=("'.addslashes($file).'");');
$file = str_replace("\\'", "'", $file);
print $file;

Dismounted
08-17-2009, 06:21 AM
Template conditionals are transformed into ternary operations (in the current version of vBulletin). The "template" is then evaluated.

The following:
<if condition="$show['guest']">Something<else />Else</if>
Is transformed into:
(($show['guest']) ? "Something" : "Else")

zethon
08-17-2009, 08:36 AM
Template conditionals are transformed into ternary operations (in the current version of vBulletin). The "template" is then evaluated.

The following:
<if condition="$show['guest']">Something<else />Else</if>
Is transformed into:
(($show['guest']) ? "Something" : "Else")

Where is this transformation happening?

Dismounted
08-17-2009, 11:30 AM
The template is transformed into raw PHP and stored in the database, therefore, it is actually done when you save the template.