PHP完全自学手册(珍藏版) 中文pdf扫描版下载
很多用dede做项目的时候会遇到channelartlist不能使用limit的苦脑
找到include\taglib\channelartlist.php
改更改代码如下
频道文档
全局标记
V55,V56,V57
获取当前频道的下级栏目的内容列表标签
typeid:频道ID
row:获取的栏目返回值
找到include\taglib\channelartlist.php
改更改代码如下
/**
* 获取当前频道的下级栏目的内容列表标签
*
* @version $Id: channelartlist.lib.php 1 9:29 2010年7月6日Z tianya $
* @package DedeCMS.Taglib
* @copyright Copyright (c) 2007 - 2010, DesDev, Inc.
* @license http://help.dedecms.com/usersguide/license.html
* @link http://www.dedecms.com
*/
/*>>dede>>
{dede:channelartlist row=6}
{dede:arclist titlelen='42' row='10'}
- ([field:pubdate function="MyDate('m-d',@me)"/])
{/dede:arclist}
{/dede:channelartlist}
>>dede>>*/
require_once(DEDEINC.'/arc.partview.class.php');
function lib_channelartlist(&$ctag,&$refObj)
{
global $dsql,$envs,$_sys_globals;
//处理标记属性、innertext
$attlist = 'typeid|0,row|20,cacheid|,limit|';
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(!preg_match('#,#', $typeid)) {
$tpsql = " reid='$typeid' AND ispart<>2 AND ishidden<>1 ";
}
else {
$tpsql = " id IN($typeid) AND ispart<>2 AND ishidden<>1 ";
}
}
$limit = trim(preg_replace('#limit#is', '', $limit));
if($limit!='') $limitsql = " LIMIT $limit ";
else $limitsql = " LIMIT 0,$totalnum";
$dsql->SetQuery("SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath
FROM `#@__arctype` WHERE $tpsql ORDER BY sortrank ASC $limitsql");
$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;
}
转载请注明:谷谷点程序 » dede channelartlist使用limit的方法