大佬教程收集整理的这篇文章主要介绍了织梦用dede:sql实现列表页分页教程方法,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
将dede:list标签进行改造,使用sql标签实现静态分页,在自定义表单调用的分页用他就很方便
例如会员列表的模板标签写法
{dede:listsql sql="SELEct * from dede_member" pagesize="10"} <li><a href="[field:id runPHP=yes]$id=@me;$url=GetOneArchive($id);@me=$url['arcurl'][/field:id]"><img src="[field:litpic/]">[field:XX /]</a></li> {/dede:listsql} <!--分页--> {dede:Pagelist/}
实现教程
打开include/arc.listview.class.PHP 找到
在下面加入
if(!is_object($ctag)) { $ctag = $this->dtp->GetTag("listsql"); if(is_object($ctag)) { $CQuery = $ctag->GetAtt("sql"); //$CQuery = str_replace('~rEID~',$this->REID,$CQuery); 这是另一个客户要求的获取url第2个参数才加的。 $CQuery = preg_replace("/SELECT(.*?)FROM/is"," SELECT count(*) as dd FROM ",$CQuery); $CQuery = preg_replace("/ORDER(.*?)SC/is","",$CQuery); $row = $this->dsql->GetOne($CQuery); if(is_array($row)) { $this->@R_352_10586@lResult = $row['dd']; } else { $this->@R_352_10586@lResult = 0; } } }
继续找到
else if($ctag->GetName()=="Pagelist")
在它上面加入
else if($ctag->GetName()=="listsql") { $limitstart = ($this->PageNo-1) * $this->PageSize; $row = $this->PageSize; if(trim($ctag->GeTinnerText())=="") { $InnerText = GetSystemplets("list_fulllist.htm"); } else { $InnerText = trim($ctag->GeTinnerText()); } $this->dtp->Assign($tagid,$this->GetsqlList( $limitstart,$row,$ctag->GetAtt("sql"),$InnerText )); }
最后找到
function GetPagelistST(
在它上面加入
function GetsqlList($limitstart = 0,$row = 10,$sql = '',$innertext) { global $cfg_list_son; $innertext = trim($innertext); if ($innertext == '') { $innertext = GetSystemplets('list_fulllist.htm'); } //处理sql语句 $limitStr = " LIMIT {$limitstart},{$row}"; $sql = str_replace('~rEID~',$sql); $this->dsql->SetQuery($sql . $limitStr); $this->dsql->Execute('al'); $t2 = Exectime(); //echo $t2-$t1; $sqllist = ''; $this->dtp2->Loadsource($innertext); $GLOBALS['autoindex'] = 0; //获取字段 while($row = $this->dsql->GetArray("al")) { $GLOBALS['autoindex']++; if(is_array($this->dtp2->CTags)) { foreach($this->dtp2->CTags as $k=>$ctag) { if($ctag->GetName()=='array') { //传递整个数组,在runPHP模式中有特殊作用 $this->dtp2->Assign($k,$row); } else { if(isset($row[$ctag->GetName()])) { $this->dtp2->Assign($k,$row[$ctag->GetName()]); } else { $this->dtp2->Assign($k,''); } } } } $sqllist .= $this->dtp2->GetResult(); }//while $t3 = Exectime(); //echo ($t3-$t2); $this->dsql->FreeResult('al'); return $sqllist; }
以上是大佬教程为你收集整理的织梦用dede:sql实现列表页分页教程方法全部内容,希望文章能够帮你解决织梦用dede:sql实现列表页分页教程方法所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。