Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Smarty, use template functions from included template

Tags:

smarty

smarty3

I have a Smarty (version 3.1.21) template like this:

<div>
    {include file='includes/test.tpl'}
    {pagebuilder data=$data.top_description}
</div>

includes/test.tpl content is:

{function name=pagebuilder}
    {foreach $data as $row}
       ...
    {/foreach}
{/function}

Error message is:

Syntax error in template "/home/master/projet/public/templates/controllers/pagebuilder-preview.tpl" on line 29 "{pagebuilder data=$data.Content}" unknown tag "pagebuilder"

How to ommit unknown tag error after include file and properly use function from included template?

like image 587
David Auvray Avatar asked Oct 21 '25 10:10

David Auvray


1 Answers

External defined template functions must be called with the {call} tag. So your base template should be rewrited into:

<div>
    {include file='includes/test.tpl'}
    # {pagebuilder data=$data.top_description} 
    {call name=pagebuilder data=$data.top_description}
</div>
like image 193
userlond Avatar answered Oct 23 '25 22:10

userlond



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!