织梦dedecms程序sql标签如何实现分页功能

雪飘落在对面的屋顶上,屋顶像蒙了一条闪着银光的纱巾,美丽极了。雪飘落在树上,树上像缀满了银色的小花。雪飘落在操场上,操场变得像铺满棉花一样白茫茫的一片。

 {dede:list pagesize='7'}{/dede:list}改用{dede:listsql}调用的方法

打开include/arc.listview.class.php

找到:

if(!is_object($ctag)) { $ctag = $this->dtp->GetTag("list"); }
这一段,在其后添加如下代码:

if(!is_object($ctag)) { $ctag = $this->dtp->GetTag("listsql"); if (is_object($ctag)) { $cquery = $ctag->GetAtt("sql"); $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->TotalResult = $row['dd']; } else { $this->TotalResult = 0; } } } //end

然后找到:

if($ctag->GetName()=="list") { $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->GetArcList( $limitstart, $row, $ctag->GetAtt("col"), $ctag->GetAtt("titlelen"), $ctag->GetAtt("infolen"), $ctag->GetAtt("imgwidth"), $ctag->GetAtt("imgheight"), $ctag->GetAtt("listtype"), $ctag->GetAtt("orderby"), $InnerText, $ctag->GetAtt("tablewidth"), $ismake, $ctag->GetAtt("orderway") ) ); }
这一段,在其后添加如下代码:

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 ) ); } //end
最后找到function GetArcList这个方法,在其后添加一个可以通过传入sql参数获取指定数据源的方法,代码如下:

/** * 通过listsql标签中sql属性传入的参数来获得一个单列的文档列表 * */ 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}"; $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; } //end

 

<script type="text/javascript"> document.body.oncopy = function (){ setTimeout(function (){ var text = clipboardData.getData("text"); if (text){ texttext = text + "rn本文转载于DeDeCms模板中心(genban.org)- 织梦模板 DEDECMS企业模板 DEDECMS仿站 dede模板下载:http://www.genban.org-原文链接:"+location.href; clipboardData.setData("text", text); } },100) } </script>



 

本文织梦dedecms程序sql标签如何实现分页功能到此结束。想去做的事情很多,所以我们得去努力,不只是想想而已。小编再次感谢大家对我们的支持!

您可能有感兴趣的文章
织梦后台文档列表添加复制文档功能支持所有模型

织梦无法上传ico图标格式文件的如何解决方法

dedecms如何实现任意页面调用当前会员信息的方

织梦dede:tag调用指定多个栏目的TAG标签

织梦栏目列表按附加表自定义字段排序