DedeCMS默认情况下顶级栏目的列表用{dede:list}调用文章,但有时候不想调用子栏目的内容。织梦系统有这个设置,找到
系统设置->系统基本参数->性能选项
在“上级列表是否包含子类内容”选择否即可。但这样是全局设置,不能对指定的栏目做单独操作。这里提供修改方法,两种标签{dede:arclist}和{dede:channelartlist}。
默认的写法
{dede:channelartlist typeid='10'} <a href="[field:arcurl/]">[field:title/]</a> {/dede:channelartlist}
这样的写法能控制调用具体哪个栏目下的文章,主要注意的是,{dede:channelartlist}同样能在列表页使用,和arclist用在列表页一样,不能分页。但{dede:channelartlist}还是会直接调用该指定栏目下的下级栏目内容。修改方法如下:
打开 /include/taglib/channelartlist.lib.php ,大概在第43行,找到:
$attlist = 'typeid|0,row|20,cacheid|';
修改为:
$attlist = 'typeid|0,row|20,cacheid|,notypeid|0'; // 此处添加了一个所要排除typeid的参数—notypeid
大概在第78行,找到:(复制时请删除“分隔符三个字”)
$dsql->SetQuery("Selectid,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath from `#@_分隔符_arctype` where $tpsql order by sortrank asc limit $totalnum");
在该段代码上加上:
if($notypeid!=0) { $tpsql = $tpsql."and not(id in($notypeid)) "; //否定指定ID }
使用方法如下:
{dede:channelartlist notypeid='10'}排除了id为10的子栏目的调用 {dede:channelartlist typeid ='7' notypeid='8'}id为7的栏目中id为8的子栏目不调用
打开/include/taglib/arclist.lib.php,找到
return lib_arclistDone ( $refObj, $ctag, $typeid, $ctag->GetAtt('row'), $ctag->GetAtt('col'), $titlelen, $infolen, $ctag->GetAtt('imgwidth'), $ctag->GetAtt('imgheight'), $listtype, $orderby, $ctag->GetAtt('keyword'), $innertext, $envs['aid'], $ctag->GetAtt('idlist'), $channelid, $ctag->GetAtt('limit'), $flag,$ctag->GetAtt('orderway'), $ctag->GetAtt('subday'), $ctag->GetAtt('noflag'), $tagid,$pagesize,$isweight );
修改为
return lib_arclistDone ( $refObj, $ctag, $typeid, $ctag->GetAtt('row'), $ctag->GetAtt('col'), $titlelen, $infolen, $ctag->GetAtt('imgwidth'), $ctag->GetAtt('imgheight'), $listtype, $orderby, $ctag->GetAtt('keyword'), $innertext, $envs['aid'], $ctag->GetAtt('idlist'), $channelid, $ctag->GetAtt('limit'), $flag,$ctag->GetAtt('orderway'), $ctag->GetAtt('subday'), $ctag->GetAtt('noflag'), $tagid,$pagesize,$isweight,$ctag->GetAtt('notypeid') );
继续找到
function lib_arclistDone(&$refObj, &$ctag, $typeid=0, $row=10, $col=1, $titlelen=30, $infolen=160, $imgwidth=120, $imgheight=90, $listtype='all', $orderby='default', $keyword='', $innertext='', $arcid=0, $idlist='', $channelid=0, $limit='', $att='', $order='desc', $subday=0, $noflag='',$tagid='', $pagesize=0, $isweight='N')
修改为
function lib_arclistDone(&$refObj, &$ctag, $typeid=0, $row=10, $col=1, $titlelen=30, $infolen=160, $imgwidth=120, $imgheight=90, $listtype='all', $orderby='default', $keyword='', $innertext='', $arcid=0, $idlist='', $channelid=0, $limit='', $att='', $order='desc', $subday=0, $noflag='',$tagid='', $pagesize=0, $isweight='N',$notypeid=0)
继续找到
$orwheres[] = ' arc.arcrank > -1 ';
下面添加
if(!empty($notypeid)) { $orwheres[] = " and arc.typeid NOT IN (".GetSonIds($notypeid).")";
使用方法
{dede:arclist row='10' orderby='rand' notypeid='10'} 不调用栏目id为10的文章 {dede:arclist row='10' orderby='rand' notypeid='10,11,12'}不调用多个栏目的文章
本文地址:https://www.vi586.com/web/744.html
版权声明:原创文章,版权归重庆SEO吖七所有,欢迎分享本文,支持原创,转载请保留出处