ecshop商品详情页面调用当前商品所属分类名称

ECSHOP开发中心在制作模板的过程中想要在详情页面调用该商品所属的商品分类的分类ID和商品名称。通过下面的方法就可以实现了,,感兴趣的朋友可以研究看看

第一步:打开goods.php

在页面最下方添加如下方法

function get_cat_info($cat_id){return $GLOBALS[‘db’]->getOne(‘SELECT cat_name FROM ‘ . $GLOBALS[‘ecs’]->table(‘category’) ." WHERE cat_id = ‘$cat_id’");}

第二步:搜索$smarty->assign(‘goods_rank’, get_goods_rank($goods_id));

在这句代码下面添加如下代码

$sql= "select cat_id from ".$GLOBALS[‘ecs’]->table(‘goods’)."where goods_id =’".$goods_id."’";$thiscat_id = $GLOBALS[‘db’]->getOne($sql);

$smarty->assign(‘thiscat_id’, $thiscat_id);$smarty->assign(‘thiscat_name’, get_cat_info($thiscat_id));

第三步:此时在goods.dwt中{$thiscat_id}就是当前商品所属的分类ID

{thiscat_name}就是当前商品所属的分类名称。在想要调用的地方,粘贴上即可

都属于昨天。哪怕那山再青,那水再秀,

ecshop商品详情页面调用当前商品所属分类名称

相关文章:

你感兴趣的文章:

标签云: