Reputation: 2300
Here is my code, I want to define a function in smarty.
{function name=menu level=0}
<ul class="level{$level}">
{foreach $data as $entry}
{if is_array($entry)}
<li>{$entry@key}</li>
{menu data=$entry level=$level+1}
{else}
<li>{$entry}</li>
{/if}
{/foreach}
</ul>
{/function}
But here is error i am getting , can someone please help ?
Fatal error: Smarty error: [in components/scripts.tpl line 1]:
syntax error: unrecognized tag 'function' (Smarty_Compiler.class.php, line 590)
in D:\xampp\htdocs\local_games\layout\default\php\Smarty\Smarty.class.php on line 1095
Upvotes: 2
Views: 1814
Reputation: 10192
{function}
is Smarty3-specific, but you are probably using Smarty2
Upvotes: 2