如何在商品列表页将商品的自定义属性调出显示?
自己在后台,设置了商品的一些属性~~
在列表页,默认只显示商品一些基本属性~~如价格等~~
而我需要将我自定义的一些属性显示在列表页~~不知道要怎么作?>
我在商品详情页模板代码中提取了部分代码放到里面不起任何作用~~
我发出我自己修改相关文件的办法,但不成功
一:改 themes\相关模板目录\librarygoods_list.lbi
在
复制内容到剪贴板
代码:
{$lang.shop_price}<span class="goods-price">{$goods.shop_price}</span>
<!--{/if}-->下面增加:
复制内容到剪贴板
代码:
<!--{if $properties or $specification}-->
<table border="1" class="goods-table">
<!-- {foreach from=$properties item=property_group key=key} -->
<!-- {foreach from=$property_group item=property} -->
<tr>
<th>{$property.name|escape:html} :</th>
<td>{$property.value|escape:html}</td>
</tr>
<!-- {/foreach}-->
<!-- {/foreach}-->
</table>
<!-- {/if}-->二:在category.php中修改:
复制内容到剪贴板
代码:
$smarty->assign('top_goods', get_top10()); // 销售排行下面增加:
复制内容到剪贴板
代码:
//添加获取商品自定义属性
$properties = get_goods_properties($goods_id); // 获得商品的规格和属性
$smarty->assign('properties', $properties['pro']); // 商品属性
$smarty->assign('specification', $properties['spe']); // 商品规格
//添加获取商品自定义属性结束三:改templates\compiled\下面的 goods_list.lbi.php 文件
复制内容到剪贴板
代码:
<p class="price">
<?php if ($this->_var['show_marketprice']): ?>
<?php echo $this->_var['lang']['market_price']; ?><span class="market-price"><?php echo $this->_var['goods']['market_price']; ?></span><br />
<?php endif; ?>
<?php if ($this->_var['goods']['promote_price'] != ""): ?>
<?php echo $this->_var['lang']['promote_price']; ?><span class="goods-price"><?php echo $this->_var['goods']['promote_price']; ?></span>
<?php else: ?>
<?php echo $this->_var['lang']['shop_price']; ?><span class="goods-price"><?php echo $this->_var['goods']['shop_price']; ?></span>
<?php endif; ?>下面增加:
复制内容到剪贴板
代码:
<!--/*在列表页显示商品自定义属性 */-->
<?php if ($this->_var['properties'] || $this->_var['specification']): ?>
<table border="1" class="goods-table">
<?php $_from = $this->_var['properties']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('key', 'property_group');if (count($_from)):
foreach ($_from AS $this->_var['key'] => $this->_var['property_group']):
?>
<?php $_from = $this->_var['property_group']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'property');if (count($_from)):
foreach ($_from AS $this->_var['property']):
?>
<tr>
<th><?php echo htmlspecialchars($this->_var['property']['name']); ?> :</th>
<td><?php echo htmlspecialchars($this->_var['property']['value']); ?></td>
</tr>
<?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
<?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
</table>
<?php endif; ?>
<!--/*在列表页显示商品自定义属性 */--> OK,完成这个之后~~~更新了缓存,但是还是不显示,我郁闷,我实在搞不懂怎么弄了~~~
[
本帖最后由 王可梦 于 2008-8-8 14:52 编辑 ]