0
J'utilise le smarty tpl.smarty tpl foreach
Maintenant, j'ai un code php et je veux l'utiliser dans tpl:
Tis est la sortie du tableau.
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 est le code php qui fonctionne:
foreach ($product_list->Result->Products as $product) {
echo $product->ProductName;
}
J'utilise le suivi du code tpl, mais cela ne fonctionne pas
//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}
Quelqu'un maintenant comment je peux résoudre ce problème?
Merci! Ça marche! – tom