|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
machnhed1 Smarty Regular
Joined: 21 Apr 2003 Posts: 39 Location: Illinois
|
Posted: Fri Apr 25, 2003 2:15 pm Post subject: Incrementing an Array |
|
|
Hi everyone,
I have been wresting with this problem for a day or so and have yet to find the right syntax. Hopefully someone here will show me the light (I'm not the most skilled at smarty).
Here's the code...
Code: | {* $Id: product.tpl,v 1.2 2002/04/23 10:38:01 mav Exp $ *}
{section name=field loop=$extra_fields}
{if $extra_fields[field].active eq "Y"}
{assign var="creator" value=$product.param00}
<tr><td width=30% valign="top">
{$extra_fields[field].field}</td>
<td>
{if %field.index% eq 0}<A href="search.php?substring={$product.param00}" {popup text="Click to see more works by $creator."}>{$product.param00}</A>{elseif %field.index% eq 1}{$product.param01}{elseif %field.index% eq 2}{$product.param02}{elseif %field.index% eq 3}{$product.param03}{elseif %field.index% eq 4}{$product.param04}{elseif %field.index% eq 5}{$product.param05}{elseif %field.index% eq 6}{$product.param06}{elseif %field.index% eq 7}{$product.param07}{elseif %field.index% eq 8}{$product.param08}{elseif %field.index% eq 9}{$product.param09}{/if}
</td>
</tr>
{/if}
{/section} |
What I would like to do is improve the intelligence of the code by adding to the if statement at the top. Right now all the extra product.param fields (00 - 09) print out regardless of whether they have information in them or not. I would like to add to the if statement so that it will only print out the product.param fields that are NOT blank.
I tried altering the if statement with something like this:
Code: | {if $extra_fields[field].active eq "Y" and $product.param.%field.index%|string_format:"%02d" ne ""} |
But the syntax is not quite right. I have tried adding backticks, quotes, apostrophes, etc., but nothing has worked yet. I couldn’t find the answer in the manual, so I hope this board can help.
Thanks in advance for any help provided! _________________ "Every operating system out there is about equal in the number of vulnerabilities reported. We all suck."
- Microsoft Senior Vice President Brian Valentine |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|