zoukankan      html  css  js  c++  java
  • 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}

    摘要,关键字同理

  • 相关阅读:
    MySQL数据模型
    Spring循环依赖
    @Autowired和@Resource区别
    Kafka概念
    阻塞队列
    线程池原理
    Spring AOP
    JVM 史上最最最完整深入解析(12000 字噢)
    Dubbo配置信息
    友情链接
  • 原文地址:https://www.cnblogs.com/lhj-blog/p/6235594.html
Copyright © 2011-2022 走看看