最近開發(fā)一個(gè)網(wǎng)站發(fā)現(xiàn)我們的DEDECMS系統(tǒng)在channel 中不能使用limit,很是著急,上網(wǎng)搜索也沒有找到解決方案。沒有辦法,只好自己研究,其實(shí)很簡單,分享出來給大家。
首先請大家打開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