IT科技资讯
联系我们
你的位置:主页 > IT科技资讯 > 正文IT科技资讯
修改dede源码,让dede:channelartlist排除指定typeid
编辑:AG集&# 发布时间:2018-11-08

修改dede源码,让dede:channelartlist排除指定凤凰娱乐平台typeid

找到 \include aglib\channelartlist.lib.php, 查找$attlist


$attlist = 'typeid|0,row|20,cacheid|';
修改为:
$attlist = 'typeid|0,row|20,cacheid|,notypeid|0'; [此处添加了一个所要排除typeid的参数---notypeid]

查找:
$dsql->SetQuery("Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath from `dede_arctype` where $tpsql order by sortrank asc limit $totalnum");

在其前面添加(注意是在前面添加):

//否定指定ID
if($notypeid!=0) {
$tpsql = $tpsql."and not(id in($notypeid)) ";
}

模板调用:
{dede:channelartlist typeid ='114' notypeid='123,124,125,126,127,128'}
其中notypeid='123,124,125,126,127,128' 中的 123,124,125,126,127,128为114的子栏目

修改后的channelartlist.lib.php

<?phpif(!defined('DEDEINC')) exit('Request Error!');require_once(DEDEINC.'/arc.partview.class.php');function lib_channelartlist(&$ctag,&$refObj){global $dsql,$envs,$_sys_globals;//处理标记属性、innertext$attlist = 'typeid|0,row|20,cacheid|,notypeid|0';FillAttsDefault($ctag->CAttribute->Items,$attlist);extract($ctag->CAttribute->Items, EXTR_SKIP);$innertext = trim($ctag->GetInnerText());$artlist = '';//读取固定的缓存块$cacheid = trim($cacheid);if($cacheid !='') {$artlist = GetCacheBlock($cacheid);if($artlist!='') return $artlist;}if(empty($typeid)){$typeid = ( !empty($refObj->TypeLink->TypeInfos['id']) ? $refObj->TypeLink->TypeInfos['id'] : 0 );}if($innertext=='') $innertext = GetSysTemplets('part_channelartlist.htm');$totalnum = $row;if(empty($totalnum)) $totalnum = 20;//获得类别ID总数的信息$typeids = array();if($typeid==0 || $typeid=='top') {$tpsql = " reid=0 And ispart<>2 And ishidden<>1 And channeltype>0 ";}else{if(!ereg(',',$typeid)) {$tpsql = " reid='$typeid' And ispart<>2 And ishidden<>1 ";}else {$tpsql = " id in($typeid) And ispart<>2 And ishidden<>1 ";}}//否定指定IDif($notypeid!=0) {$tpsql = $tpsql."and not(id in($notypeid)) ";}$dsql->SetQuery("Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath from `dede_arctype` where $tpsql order by sortrank asc limit $totalnum");$dsql->Execute();while($row = $dsql->GetArray()) {$typeids[] = $row;}if(!isset($typeids[0])) return '';$GLOBALS['itemindex'] = 0;$GLOBALS['itemparity'] = 1;for($i=0;isset($typeids[$i]);$i++){$GLOBALS['itemindex']++;$pv = new PartView($typeids[$i]['id']);$pv->Fields['typeurl'] = GetOneTypeUrlA($typeids[$i]);$pv->SetTemplet($innertext,'string');$artlist .= $pv->GetResult();$GLOBALS['itemparity'] = ($GLOBALS['itemparity']==1 ? 2 : 1);}//注销环境变量,以防止后续调用中被使用$GLOBALS['envs']['typeid'] = $_sys_globals['typeid'];$GLOBALS['envs']['reid'] = '';if($cacheid !='') {WriteCacheBlock($cacheid, $artlist);}return $artlist;}?>?

http://www.bkjia.com/dedecms/1276684.htmlwww.bkjia.comtruehttp://www.bkjia.com/dedecms/1276684.htmlTechArticle修改dede源码,让dede:channelartlist排除指定typeid 找到 \include aglib\channelartlist.lib.php, 查找$attlist 将 $attlist = typeid|0,row|20,cacheid|; 修改为: $attli...

本文源自: AG环亚国际官网

上一篇:DEDECMS模板搜索页结果调用自定义字段的完美方法
下一篇:没有了