I am trying to use foreach in my application, with php it works fine.
foreach($allowed_menus as $key=>$value){
$user_tabs[$value->TabOrder]['TabName'] = $value->TabName;
$user_tabs[$value->TabOrder]['TabDesc'] = $value->TabName;
}
But I want to use in smarty templates which is .tpl files. and I wanna try the smarty foreach.
I have even tried this
{{foreach from=$allowed_menus key=k item=v}}
{{/foreach}}
but it gives error.. internal server error.
Can anyone help me.
{foreach $allowed_menus as $value}
<a href="{$value.zig}">{$value.zag}</a>
<a href="{$value.zig2}">{$value.zag2}</a>
<a href="{$value.zig3}">{$value.zag3}</a>
{foreachelse}
There were no rows found.
{/foreach}
Your are using double braces instead of single braces so change your code to something like this.
{foreach from=$allowed_menus key=k item=v}
//foo
{/foreach}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.