首页 > 其他 > 详细

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

时间:2016-12-30 10:14:26      阅读:628      评论:0      收藏:0      [点我收藏+]

网站建设时经常需要输出某个栏目的子栏目,对应的在子栏目列表页也需要输出父级栏目的子栏目列表,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}

摘要,关键字同理

 

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

原文:http://www.cnblogs.com/lhj-blog/p/6235594.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!