[英]How to use an smarty var inside another var?
我想在我的foreach循环中获取条件为var的项目的ID。 我想尝试的(只是演示代码)如下,但这只是给我一个错误。
的PHP
$this->smarty->assign(array(
'demo' => array(
'foo_bar' => 'succeed!',
'foo_seat' => 'succeed also!'
),
'bar' => 'bar',
'seat' => 'seat'
));
tpl
value="{$demo.foo_{$bar}}"
错误
Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template "application/views/overzicht/selectie.tpl" on line 55 "{$demo.foo{$bar}}" - Unexpected "{", expected one of: "}"
谁有主意?
尝试这个
{assign var='property' value='foo_'|cat:$bar}
{$demo.$property}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.