当前分类如何获取父级分类

打开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}–>"

一个能从别人的观念来看事情,能了解别人心灵活动的人,永远不必为自己的前途担心。

当前分类如何获取父级分类

相关文章:

你感兴趣的文章:

标签云: