Answer the question
In order to leave comments, you need to log in
What is the problem with foreach in smarty 3?
Hello.
Please tell me what smarty 3 does not like in this code?
It seems that I do everything according to the documentation and manuals
require_once 'vendor/autoload.php';
$smarty = new Smarty();
//smarty config
$smarty->caching = true;
$smarty->clearAllCache(); // debug
$smarty->setCacheDir('./cache');
$smarty->setTemplateDir('./templates');
$smarty->setCompileDir('./compile');
$smarty->cache_lifetime = 300;
$arr = Array(1000, 1001, 1002);
$smarty->assign('myArray', $arr);
$smarty->display('analytics.tpl',$token);
<ul>
{foreach $myArray as $foo}
<li>{$foo}</li>
{/foreach}
</ul>
[SmartyCompilerException]
Syntax error in template "file:C:\OpenServer\domains\store.local\api\templates\analytics.tpl" on line 20 "<li>{$foo}</li>" unclosed {foreach} tag (0)
C:\OpenServer\domains\store.local\api\vendor\smarty\smarty\libs\sysplugins\smarty_internal_templatecompilerbase.php:20
#0: Smarty_Internal_TemplateCompilerBase->trigger_template_error(string)
C:\OpenServer\domains\store.local\api\vendor\smarty\smarty\libs\sysplugins\smarty_internal_smartytemplatecompiler.php:142
#1: Smarty_Internal_SmartyTemplateCompiler->doCompile(string, boolean)
C:\OpenServer\domains\store.local\api\vendor\smarty\smarty\libs\sysplugins\smarty_internal_templatecompilerbase.php:481
#2: Smarty_Internal_TemplateCompilerBase->compileTemplateSource(object, NULL, NULL)
C:\OpenServer\domains\store.local\api\vendor\smarty\smarty\libs\sysplugins\smarty_internal_templatecompilerbase.php:405
#3: Smarty_Internal_TemplateCompilerBase->compileTemplate(object)
C:\OpenServer\domains\store.local\api\vendor\smarty\smarty\libs\sysplugins\smarty_template_compiled.php:184
#4: Smarty_Template_Compiled->compileTemplateSource(object)
C:\OpenServer\domains\store.local\api\vendor\smarty\smarty\libs\sysplugins\smarty_template_compiled.php:141
#5: Smarty_Template_Compiled->process(object)
C:\OpenServer\domains\store.local\api\vendor\smarty\smarty\libs\sysplugins\smarty_template_compiled.php:105
#6: Smarty_Template_Compiled->render(object)
C:\OpenServer\domains\store.local\api\vendor\smarty\smarty\libs\sysplugins\smarty_internal_runtime_updatecache.php:38
#7: Smarty_Internal_Runtime_UpdateCache->updateCache(object, object, boolean)
C:\OpenServer\domains\store.local\api\vendor\smarty\smarty\libs\sysplugins\smarty_template_cached.php:143
#8: Smarty_Template_Cached->render(object, boolean)
C:\OpenServer\domains\store.local\api\vendor\smarty\smarty\libs\sysplugins\smarty_internal_template.php:211
#9: Smarty_Internal_Template->render(boolean, integer)
C:\OpenServer\domains\store.local\api\vendor\smarty\smarty\libs\sysplugins\smarty_internal_templatebase.php:232
#10: Smarty_Internal_TemplateBase->_execute(string, string, NULL, NULL, integer)
C:\OpenServer\domains\store.local\api\vendor\smarty\smarty\libs\sysplugins\smarty_internal_templatebase.php:134
#11: Smarty_Internal_TemplateBase->display(string, string)
C:\OpenServer\domains\store.local\api\index.php:40
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question