Everyone!
I'm working with PHP and Smarty in my project. I'm using namespaces and I'm having a problem when I call Smarty functions, for sample cycle
I'm having this error: Syntax Error in template ".\sys\adm\template\fields\inputFileField.tpl" on line 23 "{cycle values="um,dois"}" unknown tag "cycle"
I'm using spl_autoload_register to auto load classes in project:
function smartyAutoloader($className) {
$file = "sys/classes/smarty/$className.class.php";
if (file_exists($file)) {
require $file;
return true;
}
return false;
}
I did not change the namespace in Smarty class, so I'm importing Smarty this way:
use \Smarty;
If I comment the cycle code, my code works correctly.
Follow is the problemmatic code:
{for $x = 0 to 10}
{cycle values="um,dois"} {*line 23 on inputFileField.tpl*}
{/for}
I'm not knowing to use namespace and Smarty in same project. I'm sure this error is because of namespaces. Can someone help me?
Thanks in advance
I found this post at the Smarty forum
The problem seems to be a wrong or relative path to the plugin folder. After setting the path to the plugin folder absolut, it works fine, even with namespaces.
Have also a look at the Smarty documentation: