ferym
@ferym
Web-Developer

В чём проблема с foreach в smarty 3?

Здравствуйте.
Подскажите пожалуйста что не нравится smarty 3 в этом коде?
Вроде делаю всё по документации и мануалам

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
  • Вопрос задан
  • 173 просмотра
Пригласить эксперта
Ответы на вопрос 1
@antimind
{foreach from=array item=item}
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы