日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

dede php分页代码,织梦用dede:sql实现列表页分页教程方法

發布時間:2023/12/31 php 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 dede php分页代码,织梦用dede:sql实现列表页分页教程方法 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

將dede:list標簽進行改造了,熟悉dede的朋友應該知道這個列表頁專用標簽的工作原理大致是先通過欄目變量id獲取到對應的數據源再呈現到頁面上來,那么我們就可以讓它不僅僅通過欄目變量id還可以通過指定的sql語句來獲取數據源了。

例如會員列表的模板標簽寫法

{dede:listsql sql="select * from #@__member" pagesize="10"}

[field:XX /]

{/dede:listsql}

{dede:pagelist/}

實現教程

打開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 = 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->TotalResult = $row['dd'];

}

else

{

$this->TotalResult = 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~',$this->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 php分页代码,织梦用dede:sql实现列表页分页教程方法的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。