Error with php tag on smarty

0

I'm having a question regarding the template engine smarty 3.1, I'm trying to use the {php} tags in the templates and I'm getting the following error:

  

Fatal error: Uncaught - > Smarty Compiler: Syntax error in template "file: /var/www/html/caf/view/index.tpl" on line 67 "{php}" {php} {php} tags not allowed. Use SmartyBC to enable them

asked by anonymous 18.03.2018 / 23:46

1 answer

1

I found my problem, if anyone has this doubt in the future the solution I found in my case was to use the registerPlugin method of smarty which according to the documentation is recommended, and in my case described above the solution looks like this: / p>

$smarty->registerPlugin("function", "get_page", array("Rotas", "getPage"));

To call the plugin in the template just use the name you gave it, inside keys:

{get_template}

Note: the plugin name can not have the same name as your method / function because of the error (I took time to find out this).

registerPlugin documentation link

    
19.03.2018 / 01:21