...

View Full Version : if statements in joomla .tpl file



countrygirl
06-25-2010, 06:59 AM
I would imagine this is the wrong forum for this and I apologize in advance but I didn't know which one to use. I also tried asking this question in the joomla forums but noone had the answer for me. I am using a joomla extension called form2content and the template files must have the extension .tpl I am trying to put an if statement in there to only show certain things at certain times but I can't seem to get it to work properly. I have done tons of research on this and can not find the answer so I was hoping someone might have enough experience with .tpl files to help me out here. Any help would be greatly appreciated. I have tried many things nothing has worked but here is my code right now:


<mos:tmpl name="root">
<!--[IF (HORSESIRE != "")]-->
<p><strong>{HORSENAME}'s Pedigree Information:</strong></p>

<table cellpadding="0" cellspacing="1" width="75%">
<tr>
<td rowspan="4" class="maternal">{JOOMLA_TITLE}</td>
<td rowspan="2" class="maternal">{HORSESIRE}</td>
<td class="maternal">{HORSEGRANDSIRESIRE}</td>
</tr>
<tr>

<td class="paternal">{HORSEGRANDDAMSIRE}</td>
</tr>
<tr>
<td rowspan="2" class="paternal">{HORSEDAM}</td>
<td class="maternal">{HORSEGRANDSIREDAM}</td>
</tr>
<tr>
<td class="paternal">{HORSEGRANDDAMDAM}</td>
</tr>
</table>
<!--[ELSE IF (HORSEPHOTO1 != "")]-->
<p><strong>Photos of {HORSENAME}</strong></p>
<p>Click on any of the images below to view a larger image. When you are done, simply click close to return to this page</p>
<table class="pics">
<tr>
<td>{HORSEPHOTO1}</td>
<td>{HORSEPHOTO2}</td>
<td>{HORSEPHOTO3}</td>
<td>{HORSEPHOTO4}</td>
<td>{HORSEPHOTO5}</td>
<td>{HORSEPHOTO6}</td>
</tr>
</table>
<!--[ELSE IF (FOAL4SALE1PIC != "")]-->
<p><strong>{HORSENAME} has the following foals which are for sale:</strong></p>
<table class="pics">
<tr>
<td align="center">{FOAL4SALE1PIC}</td>
<td align="center">{FOAL4SALE2PIC}</td>
<td align="center">{FOAL4SALE3PIC}</td>
<td align="center">{FOAL4SALE4PIC}</td>
<td align="center">{FOAL4SALE5PIC}</td>
<td align="center">{FOAL4SALE6PIC}</td>
</tr>
<tr>
<td class="caption">{FOAL4SALE1}</td>
<td class="caption">{FOAL4SALE2}</td>
<td class="caption">{FOAL4SALE3}</td>
<td class="caption">{FOAL4SALE4}</td>
<td class="caption">{FOAL4SALE5}</td>
<td class="caption">{FOAL4SALE6}</td>
</tr>
<tr>
<td align="center">{FOAL4SALE7PIC}</td>
<td align="center">{FOAL4SALE8PIC}</td>
<td align="center">{FOAL4SALE9PIC}</td>
<td align="center">{FOAL4SALE10PIC}</td>
<td align="center">{FOAL4SALE11PIC}</td>
<td align="center">{FOAL4SALE12PIC}</td>
</tr>
<tr>
<td class="caption">{FOAL4SALE7}</td>
<td class="caption">{FOAL4SALE8}</td>
<td class="caption">{FOAL4SALE9}</td>
<td class="caption">{FOAL4SALE10}</td>
<td class="caption">{FOAL4SALE11}</td>
<td class="caption">{FOAL4SALE12}</td>
</tr>
</table>
<!--[endif]-->
</mos:tmpl>

santhoshj400
07-12-2010, 12:26 PM
hi in smarty we will be using like this for the if statements hope this is what you are looking too



{if $grantname[i] == $grant_idd[i]}
<input type="checkbox" name="grantname{$smarty.section.i.index}" value="{$grant_idd[i]}" checked="true">{$grantnamed[i]}<br>
{else}
<input type="checkbox" name="grantname{$smarty.section.i.index}" value="{$grant_idd[i]}">{$grantnamed[i]}<br>
{/if}


Thanks and Regards
Santhosh



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum