Reputation: 8463
<div id="favorite-first" class="">
{foreach from=$arrSection key=k item=v}
{if $k==$selectedSection}
{$v}
{/if}
{/foreach}
</div>
<div id="favorite-toggle"><br></div>
<div id="favorite-inside" class="slideUp">
{foreach from=$arrSection key=k item=v}
{if $k==$selectedSection}
{else}
<div class="favorite-action" id="{$k}"><a href="javascript: section_submit({$k});">{$v}</a></div>
{/if}
{/foreach}
</div>
If $arrSection array returns only one value (i.e $k). I need to hide div (favorite-toggle,favorite-inside) How can i do this in smarty
Upvotes: 0
Views: 555
Reputation: 2385
If you give the "foreach" a name argument you can access certain foreach properties:
{foreach from=$arrSection key=k item=v name=NAME}
Let's say the number of iterations in total:
$smarty.foreach.NAME.total
Then you now how often smarty will loop and if it's in your case only one time.
Upvotes: 0
Reputation: 254926
If $arrSection array returns only one value
{if count($arrSection) eq 1}
there is only one item
{else}
there is > one or zero items
{/if}
Upvotes: 1