我试图在Prestashop 1.6.1.5中修改模块。我使用foreach循环在印刷价值方面非常聪明。
我有聪明的数组$obchody
Array
(
[0] => Array
(
[id] => 2
[active] => 1
[mesto] => Praha
[vzdalenost] => 86
[name] => Praha - rozvoz
[address1] => Praha
[address2] =>
[postcode] => 10200
[latitude] => 25.94896900
[longitude] => -80.22643900
[hours] => a:7:{i:0;s:0:"";i:1;s:0:"";i:2;s:0:"";i:3;s:0:"";i:4;s:0:"";i:5;s:0:"";i:6;s:0:"";}
[phone] =>
[fax] =>
[note] =>
[email] =>
)
[1] => Array
(
[id] => 3
[active] => 1
[mesto] => Aš
[vzdalenost] => 133
[name] => Aš - rozvoz
[address1] => Aš
[address2] =>
[postcode] => 35201
[latitude] => 25.94896900
[longitude] => -80.22643900
[hours] => a:7:{i:0;s:0:"";i:1;s:0:"";i:2;s:0:"";i:3;s:0:"";i:4;s:0:"";i:5;s:0:"";i:6;s:0:"";}
[phone] =>
[fax] =>
[note] =>
[email] =>
)
[2] => Array
(
[id] => 1
[active] => 1
[mesto] => Liberec
[vzdalenost] => 192
[name] => Liberec - rozvoz
[address1] => Liberec
[address2] =>
[postcode] => 46001
[latitude] => 25.94896900
[longitude] => -80.22643900
[hours] => a:7:{i:0;s:0:"";i:1;s:0:"";i:2;s:0:"";i:3;s:0:"";i:4;s:0:"";i:5;s:0:"";i:6;s:0:"";}
[phone] =>
[fax] =>
[note] =>
[email] =>
)
)
我尝试使用
在我的模板中获取[name]
值
{foreach $obchody as $obchod}
{$obchod->name}
{/foreach}
但我总是只注意到"注意:试图在...中获得非对象的属性"。我尝试了{$obchod[0]->name}
同样的结果。我做错了什么?
答案 0 :(得分:0)
打印properties of associative arrays的语法是{$array.key}
。
因此,您的数据结构的Smarty代码应为:
{foreach $obchody as $obchod}
{$obchod.name}
{/foreach}
阅读如何处理Smarty文档中的assigned variables。