dede使用channelartlist在列表页和内容页调用同级栏目的方法

时间:2016-12-24 14:06 / 来源:未知 / 作者:酱油 / 点击:

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

找到\include\taglib\channelartlist.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
DEDECMS

DEDE使用经验和技巧

WordPress
Wordpress

WP使用经验和技巧

Zblog
Zblog

Zblog使用经验和技巧

CSS
CSS

CSS使用经验和技巧

网络资料
网络资料

转载实用网络资料

按键伤人
按键伤人

转载乱七八糟的网络资源

我是酱油
我是酱油

随笔札记 记录生活点滴

本站推荐

百度站内搜索

专业博客主机