我们后台设定ecshop属性列表,存在两种设定方式商品属性显示样式: 单选按钮 与下拉列表,但是有时候可能我们需要让ecshop商品同时支持下拉与单选按钮,怎么办?
这里最模板提供简单的一个方法
在ecshop设定属性值时,如一般否进行检索 ,我们都不会选择,那么可以设定起来,在系统当中以这个为参照来判断。
用到的字段attr_index 值为1
1. 找到系统lib_goods.php文件,函数get_goods_properties。增加属性spe的值
此段改成:
foreach ($res AS $row) {
$row['attr_value'] = str_replace("/n", '
', $row['attr_value']);
if ($row['attr_type'] == 0) {
$group = (isset($groups[$row['attr_group']])) ? $groups[$row['attr_group']] : $GLOBALS['_LANG']['goods_attr'];
$arr['pro'][$group][$row['attr_id']]['name'] = $row['attr_name'];
$arr['pro'][$group][$row['attr_id']]['value'] = $row['attr_value'];
} else {
$arr['spe'][$row['attr_id']]['attr_type'] = $row['attr_type'];
$arr['spe'][$row['attr_id']]['name'] = $row['attr_name'];
$arr['spe'][$row['attr_id']]['attr_index'] = $row['attr_index'];
$arr['spe'][$row['attr_id']]['values'][] = array(
'label' => $row['attr_value'],
'price' => $row['attr_price'],
'format_price' => price_format(abs($row['attr_price']), false),
'id' => $row['goods_attr_id']);
}
2,在模板当中判断
{$value.label} [{if $value.price gt 0}{$lang.plus}{elseif $value.price lt 0}{$lang.minus}{/if} {$value.format_price|abs}]
标红部分 就是主要判断部分。这样ecshop属性列表展示列表方式与单选按钮同时存在了。
评论列表()