注册 | 登录 |
地方论坛门户及新闻和人才网址大全

dede教程:织梦使用channelartlist在列表页和内容页

时间:2021-07-21人气:-


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

本文将给一种更简单的办法

找到includetaglibchannelartlist.lib.php文件,查找:$attlist = 'typeid|0,row|20,cacheid|';

修改为:

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

然后查找:

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

修改为:

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

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

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

就可以方便调用了。


上篇:DEDECMS删除指定IP的评论

下篇:dedecms教程:优化织梦提高文章页显示速度的方法