最近开发一个网站发现我们的DEDECMS系统在channel 中不能使用limit,很是着急,上网搜索也没有找到解决方案。没有办法,只好自己研究,其实很简单,分享出来给大家。
首先请大家打开include/taglib/channel.lib.php文件,然后找到
1.在$line = empty($row) ? 100 : $row;在它的下面加上下面代码
//limit条件 $limit = trim(eregi_replace('limit','',$limit)); if($limit!=''){ $limit = " $limit "; }else{ $limit = " limit 0,$line "; }
2.然后把下面的
if($type=='top') { $sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath From `80php_arctype` WHERE reid=0 And ishidden<>1 order by sortrank asc limit 0, $line "; } else if($type=='son') { if($typeid==0) return ''; $sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath From `80php_arctype` WHERE reid='$typeid' And ishidden<>1 order by sortrank asc limit $limit "; } else if($type=='self') { if($reid==0) return ''; $sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath FROM `80php_arctype` WHERE reid='$reid' And ishidden<>1 order by sortrank asc limit 0, $line "; }
将limit 0, $line 改成$limit
3.使用方法:
{dede:channel type='son' typeid=68 limit='0,6'} <a href="[field:typeurl/]">[field:typename/]</a> {/dede:channel}
Copyright © 2009-2019 Ywcms.Com All Right Reserved. 湘ICP备16006489号-2