修改dede源码,让dede:channelartlist排除指定typeid

前端之家收集整理的这篇文章主要介绍了修改dede源码,让dede:channelartlist排除指定typeid前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

找到 \include\taglib\channelartlist.lib.PHP,  查找 $attlist

将 
$attlist = 'typeid|0,row|20,cacheid|';
修改为:
$attlist = 'typeid|0,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,128' 中的 123,128 为114的子栏目
 

修改后的channelartlist.lib.PHP
 

PHP
 
if(!defined('DEDEINC')) exit('Request Error!');
require_once(DEDEINC.'/arc.partview.class.PHP');
 
function lib_channelartlist(&$ctag,&$refObj)
{
    global $dsqlPHP plain" style="font-family: Consolas,$envs$_sys_globals;
 
    //处理标记属性、innertext
    $attlist = 'typeid|0,notypeid|0';
    FillAttsDefault(->CAttribute->Items,0) !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; Box-sizing: content-Box !important; font-size: 1em !important; background: none !important;">$attlist);
extract(PHP variable" style="font-family: Consolas,EXTR_SKIP);
$innertext = trim(->GetInnerText());
$artlist '';
//读取固定的缓存块
$cacheid $cacheid);
(!=) {
        = GetCacheBlock();
        $artlist) return ;
}
    
(empty$typeid))
{
$typeid = ( !->TypeLink->TypeInfos['id']) ?  ] : 0 );
}
    
$innertext==) = GetSysTemplets('part_channelartlist.htm');
$totalnum = $row;
$totalnum)) = 20;
 
//获得类别ID总数的信息
$typeids = array();
==0 || 'top') {
$tpsql " reid=0 And ispart<>2 And ishidden<>1 And channeltype>0 ";
}
else
{
(!ereg',')) {
            " reid='$typeid' And ispart<>2 And ishidden<>1 ";
        }
else {
" id in($typeid) And ispart<>2 And ishidden<>1 ";
}
}
    
//否定指定ID
$notypeid!=0) {
$tpsql."and not(id in($notypeid)) ";
}
    
->SetQuery("Select id,sitepath
                                            from `dede_arctype` where order by sortrank asc limit ");
->Execute();
while$row ->GetArray()) {
$typeids[] = ;
}
@H_403_378@  
(!isset([0])) return ;
 
$GLOBALS['itemindex'] = 0;
'itemparity'] = 1;
for$i=0;isset([]);++)
{
]++;
$pv new PartView(][]);
$pv->Fields['typeurl'] = GetOneTypeUrlA(]);
->SetTemplet(PHP variable" style="font-family: Consolas,'string');
.= ->GetResult();
] = (]==1 ? 2 : 1);
}
//注销环境变量,以防止后续调用中被使用
'envs''typeid'] = ];
'reid'] = ;
) {
WriteCacheBlock();
}
;
}
?>
?
 

原文链接:https://www.f2er.com/dedecms/451589.html

猜你在找的Dedecms相关文章