A5下载文章资讯

分类分类

Ecshop 分类页面 获取顶级分类ID 获取父类ID

2015-04-07 16:01作者:zhao

打开category.php页面

步骤一:找到“ $smarty->assign('ur_here', $position['ur_here']); // 当前位置”(大概在334行),在这行下面加上以下代码。

$smarty->assign('current_cat_id', $cat_id); //取得当前的id

$catlist = array();

foreach(get_parent_cats($cat_id) as $k=>$v)

{ $catlist[] = $v['cat_id']; }

$smarty->assign('current_cat_pr_id',$catlist[count($catlist)-1]);

if (count($catlist)>=2)

{ $smarty->assign('current_cat_t_id',$catlist[count($catlist)-2]); }

步骤二:在模板库文件中直接引用就可以了,代码如下:

$current_cat_pr_id

判断是否与当前分类ID是否相等,引用不同Css模板,代码以下:

class="<!--{if $current_cat_pr_id eq $cat.id}-->haha<!--{else}-->hb<!--{/if}-->"

展开全部

相关

说两句网友评论
    我要跟贴
    取消