PDA

View Full Version : question regarding <if> in templates


Vitesse
09-17-2005, 03:16 PM
I'm writing a few custom pages for my site, one of which is an email form. I have a varaible in the PHP called $sendfail which is set to 0 or 1 depending if the email sent correctly. How can i check this value using <if> in the template so i can display the relevant message? I presumed it would have been <if $sendfail == "0"> but this doesnt seem to work.

Any help would be great, thanks

Marco van Herwaarden
09-17-2005, 04:52 PM
<if condition="$sendfail">
......
</if>

Vitesse
09-17-2005, 06:43 PM
so can i test that for a matching value like

<if condition $sendfail == "0"> Do something if it was equal to zero </if>
<if condition $sendfail =="1"> Do something else here if it was equal to 1 </if>


I think i kinda worded that badly, what i want to do is check if the variable $sendfail in my php script has a value of 1 or 0, and could i also do an IF that checks the value of a string, like

<if $sentto == "The Admin Team"> do something </if>


Would that syntax be correct or am i getting totally wrong?

Marco van Herwaarden
09-17-2005, 07:04 PM
Yes both are correct. Since the $sendfail is a boolean, you could also just perform the test like i gave in my example above.

Vitesse
09-17-2005, 09:25 PM
For some reason this just will not work, here's a bit of my template:

<tr>

<td class="alt1">Here we have added all the websites of interest for everything from Engine tuners and performance parts retailers to buying those hard to find cables for you ICE install. This is what the var contains: $showcategory
<if $showcategory == "Display body retailers"> Some test text here</if>
</td></tr>


The var $showcategory is set to either "SHOW ALL" or "Display body retailers" but either way the test text in between the IF is still being displayed, the variable is definately being changed but the IF is always treating it as true. Any ideas?

Paul M
09-17-2005, 09:39 PM
The format is <if condition="xxxxxxx"> ....... </if>

Where xxxxxx is what you want to test - so in your example above you need ;

<if condition=" $showcategory == 'Display body retailers' ">

Vitesse
09-17-2005, 09:44 PM
Nice one :D that works a treat now. Thankyou