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}

    摘要,关键字同理

  • 相关阅读:
    AOP概述
    AOP-动态代理
    IOC容器和Bean的配置
    Spring框架概述
    异常
    Optional 类
    Stream API
    方法引用(Method References)
    函数式(Functional)接口
    stm8笔记1-搭建工程+孤独的小灯闪烁
  • 原文地址:https://www.cnblogs.com/lhj-blog/p/6235594.html
Copyright © 2011-2022 走看看