我使用 smarty tpl。
现在我有一个 php 代码,我想在 tpl 中使用它:
Tis 是数组的输出。
stdClass Object
(
[Status] => success
[Time] => 2011-01-01 12:00:00
[IP] => 12.34.56.789
[Count] => 1
[Filter] => stdClass Object
(
[Sort] => ProductCode
[Order] => DESC
[Search] =>
[ProductCode] => P001
[ProductType] =>
)
[Result] => stdClass Object
(
[Products] => Array
(
[0] => stdClass Object
(
[Identifier] => 1
[ProductCode] => test
[ProductName] => test
)
)
)
Tis 是有效的 php 代码:
foreach ($product_list->Result->Products as $product) {
echo $product->ProductName;
}
我使用以下 tpl 代码,但这不起作用
//in php
$smarty->assign("data", $product_list);
//in tpl file
{foreach item=item from=$data}
<tr>
<td align="center">{$item.Result->Products->ProductName}</td>
<td align="center"></td>
<td align="center"></td>
<td align="center"><a href="" class="usuallink">{$header.order}</a></td>
</tr>
{/foreach}
有谁现在我可以解决这个问题?