4

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?

userlond
  • 3,632
  • 2
  • 36
  • 53
David Auvray
  • 288
  • 1
  • 3
  • 20

2 Answers2

2

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>
userlond
  • 3,632
  • 2
  • 36
  • 53
0

try using assign:

{include file='includes/test.tpl' assign=pagebuilder}
Lukas Liesis
  • 24,652
  • 10
  • 111
  • 109