我坚持使用 smarty 中的这种多维数组处理(更准确地说是 prestashop)。
我在遍历所有元素时遇到了麻烦。
这是我的数组,print_r-ed。
(
[0] => Array
(
[superorder] => 1
[basket] => Array
(
[0] => Array
(
[product_name] => iPod shuffle
[position_left] => 37
[position_top] => 73
[order] => 1
)
[1] => Array
(
[product_name] => iPod touch
[position_left] => 5
[position_top] => 66
[order] => 2
)
[2] => Array
(
[product_name] => iPod Nano
[position_left] => 67
[position_top] => 49
[order] => 3
)
)
)
[1] => Array
(
[superorder] => 2
[basket] => Array
(
[0] => Array
(
[product_name] => iPod shuffle
[position_left] => 37
[position_top] => 73
[order] => 1
)
[1] => Array
(
[product_name] => iPod touch
[position_left] => 5
[position_top] => 66
[order] => 2
)
[2] => Array
(
[product_name] => iPod Nano
[position_left] => 67
[position_top] => 49
[order] => 3
)
)
)
)
这就是我正在尝试使用的,但失败得很惨:
{foreach from=$all_baskets name=outer key=superorder item=basket}
<div superorder="{$basket.superorder}" >
{foreach from=$basket name=inner key=i item=basket_image}
<div product_name="{$basket_image.product_name}" order="{$basket_image.order}" style="left:{$basket_image.position_left}px; top:{$basket_image.position_top}px"></div>
{/foreach}
</div>
{/foreach}
我是 smarty 的新手,我知道我做错了什么,所以我希望你能帮助我。谢谢!