php - Get array first key value in Smarty -


this code navigation

<ul class="sortlist">    <li class="first"><strong>{$smarty.const.lbl_sortby}: </strong></li>                {foreach  $listsortby $key=>$filterby}        <li class="filterlink"><a href="javascript:void(0);" id="{$key}" class="current"  >{$filterby}</a> </li>     {/foreach} </ul> 

and here want first key, , add class="current"

and rest empty.

how first value , add class name first navigation? in advance

edited answer after found out better way :)

{foreach name=listsortby from=$listsortby item=elesortby key=elesortby_key}     <li class="filterlink"><a href="javascript:void(0);"      {if $smarty.foreach.listsortby.first}         class="current"     {/if}     id="{$elesortby_key}">{$elesortby}</a> </li> {/foreach} 

marcel has noted in comments of smarty 3 can use @first instead of old hat implementation :)

{foreach name=listsortby from=$listsortby item=elesortby key=elesortby_key}     <li class="filterlink"><a href="javascript:void(0);"      {if $elesortby@first}         class="current"     {/if}     id="{$elesortby_key}">{$elesortby}</a> </li> {/foreach} 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -