1、在开发中我们常常会因不知道后台模板提供给前台的有哪些键及其对应的键值,这给我们的开发造成了不便。我们可以采用如下方式来查看
(以”已购买过此商品的人还购买了”模块为例)
{if $bought_goods}
<ul>
{foreach from=$bought_goods item=bought}
<li style="float:left;">
<a href="{$bought.url}" title="{$bought.goods_name}">
<img src="{$bought.goods_thumb}" alt="">
{$bought.short_name}
<!-- {if $bought.promote_price neq 0} -->
<font class="shop_s">{$bought.formated_promote_price}</font>
<!-- {else} -->
<font class="shop_s">{$bought.shop_price}</font>
<!-- {/if} -->
</a>
</li>
{foreach from=$bought item=bought_v key=key}
#遍历取出键值
<p>{$key}--{$bought_v}</p>
{/foreach}
{/foreach}
</ul>
2、输出如下
goods_id--24
goods_name--P806
short_name--P806
goods_thumb--images/200905/thumb_img/24_thumb_G_1241971981429.jpg
goods_img--images/200905/goods_img/24_G_1241971981284.jpg
shop_price--¥2000元
url--goods.php?id=24
promote_price--0
formated_promote_price--¥0元