zoukankan      html  css  js  c++  java
  • 织梦dedecms调用同级栏目的方法,使用channelartlist在列表页和内容页调用同栏目文章

     使用织梦dedecms时,想在列表页和内容页调用同级栏目的文章,当然可以使用{dede:channelartlist typeid=‘1’ row='5'}的方法,指定栏目id,但是要自动判断当前栏目的同级栏目就没办法了或者需要给每个顶级栏目分配一个模板,这样很麻烦。本文将给一种更简单的办法:

    1.找到include aglibchannelartlist.lib.php 文件
     

    查找:

     $attlist = 'typeid|0,row|20,cacheid|'; 

    修改为:

    $attlist = 'typeid|0,row|20,cacheid|,type|';     //这边加个 type 实现 在子栏目下调用   同级子栏目的信息

    然后查找:

    1.  
      if($typeid==0 || $typeid=='top') {
    2.  
              $tpsql = " reid=0 AND ispart<>2 AND ishidden<>1 AND channeltype>0 ";
    3.  
          }

    修改为:

    1.  
      if($type=='reid')    //调用上级目录下的子栏目内容
    2.  
            {        
    3.  
              $reid = $refObj->TypeLink->TypeInfos['reid'];          
    4.  
              $tpsql = " reid='$reid' AND ispart<>2 AND ishidden<>1 ";
    5.  
            }
    6.  
          else if($typeid==0 || $typeid=='top') {
    7.  
              $tpsql = " reid=0 AND ispart<>2 AND ishidden<>1 AND channeltype>0 ";
    8.  
          }

    保存上面文件。然后在列表页或者内容页使用:

    1.  
      {dede:channelartlist type='reid' row='5'}
    2.  
      底层循环代码
    3.  
      {/dede:channelartlist}  

    就可以方便调用了。

  • 相关阅读:
    bzoj 1084: [SCOI2005]最大子矩阵
    Python之深浅拷贝
    2,版本控制git --分支
    1,版本控制git--仓库管理
    python-openpyxl操作excel
    ansible-3
    ansible-2
    ansible-1
    celery
    6,MongoDB 之 Array Object 的特殊操作
  • 原文地址:https://www.cnblogs.com/lanne/p/dedecms.html
Copyright © 2011-2022 走看看