Thinkcmf子栏目获取父级栏目所有子栏目列表

网站建设时经常需要输出某个栏目的子栏目,对应的在子栏目列表页也需要输出父级栏目的子栏目列表,thinkcmf可以输出所有子栏目,但却无法在子栏目列表页也适用,

因此就需要通过对数据库表查询来完成需求:

<?php $RS = M('terms')->where(array('term_id'=>$term_id))->find(); 
    $parent = M('terms')->where(array('term_id'=>$RS['parent']))->find();
?>

本方法通过查询terms表找到其父级,然后输出子级栏目,

1 <php>
2      $term_id=$term_id;
3      $terms=sp_get_child_terms($RS['parent']); //获取子分类信息
4 </php>
5 <foreach name="terms" item="vo">
6     {$vo.name}
7 </foreach>

同样,需要查询父级栏目名字:

1 {$parent.name}

摘要,关键字同理

 

posted @ 2016-12-30 09:09  诩小贝  阅读(2343)  评论(0编辑  收藏  举报
Copyright ©2016 诩小贝   联系QQ:980823367