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}

摘要,关键字同理

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM