I wonder if anyone can help me. I’m using PodHawk – a basic podcast cms, I would like the admin area file select to show my files in order – by name.
The select/option dropdown uses this code, is there a straightforward way to get the dropdown to display in order by name,. I’ve searched but cant find anything in the Smarty documentation, but I’m probably using the wrong terminology!
{foreach from=$upload item=file}
<option value="{$file|escape:'url'}">{$file}</option>
{/foreach}
many thanks rob
Solved with many thanks to poster below –
{$upload|@sort:$smarty.const.SORT_NUMERIC}
{foreach from=$upload item=file}
<option value="{$file|escape:'url'}">{$file}</option>
{/foreach}
cgwyllie neglected that asort() returns a boolean, not the sorted array. So his approach wouldn’t work. As the index is not used, a(ssociative)sort is not required.
should do the trick. Make sure you really need that $file urlencoded, otherwise change escape:”url” to escape:”html”.
(the above is Smarty3 syntax)