織夢前臺欄目和分頁
織夢后臺欄目數(shù)據(jù)
需求描述
一個織夢欄目就是一個小說,炒雞輕松實現(xiàn)按欄目分頁
不影響程序其他功能文檔分頁
支持動態(tài)、生成靜態(tài)、偽靜態(tài)
可擴(kuò)展其他分頁,例如會員分頁,自定義表單分頁
實現(xiàn)教程
打開 /include/arc.listview.class.php 找到 大概在248行
$ctag = $this->dtp->GetTag("page");
在它下面加入
if(!is_object($ctag)) { $ctag = $this->dtp->GetTag("listsql"); if(is_object($ctag)) { $this->addSql = " WHERE ishidden<>1 "; if($cfg_list_son=='N') { if($this->CrossID=='') $this->addSql .= " AND (id='".$this->TypeID."') "; else $this->addSql .= " AND (id in({$this->CrossID},{$this->TypeID})) "; } else { $sonids = GetSonIds($this->TypeID,$this->Fields['channeltype'],0); if(!preg_match("/,/", $sonids)) { $this->addSql .= " AND id = '$sonids' "; } else { $this->addSql .= " AND id IN($sonids) "; } } $sql = $ctag->GetAtt("sql"); $sql = preg_replace("/SELECT(.*?)FROM/is", " SELECT count(*) as dd FROM ", $sql); $sql = preg_replace("/ORDER(.*?)SC/is", "", $sql); $sql = $sql.$this->addSql; $row = $this->dsql->GetOne($sql); if(is_array($row)) { $this->TotalResult = $row['dd']; } else { $this->TotalResult = 0; } } }
繼續(xù)找到
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 )); }
繼續(xù)找到
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 = $sql.$this->addSql.$limitStr; $this->dsql->SetQuery($sql); $this->dsql->Execute('al'); $t2 = ExecTime(); //echo $t2-$t1; $sqllist = ''; $this->dtp2->LoadSource($innertext); $GLOBALS['autoindex'] = 0; //獲取字段 while($row = $this->dsql->GetArray("al")) { $row['typeurl'] = GetTypeUrl($row['typeid'],MfTypedir($row['typedir']),$row['isdefault'],$row['defaultname'], $row['ispart'],$row['namerule2'],$row['moresite'],$row['siteurl'],$row['sitepath']); $row['typelink'] = GetOneTypeUrlA($row); $GLOBALS['autoindex']++; if(is_array($this->dtp2->CTags)) { foreach($this->dtp2->CTags as $k=>$ctag) { if($ctag->GetName()=='array') { //傳遞整個數(shù)組,在runphp模式中有特殊作用 www.lol9.cn六久閣織夢模板網(wǎng) $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; }
注意:上面添加代碼,有的是添加在上面有的是添加在下面的,看清楚了。
欄目模板標(biāo)簽寫法
<h2>欄目列表</h2> <ul> {dede:listsql sql="select * from dede_arctype" pagesize="10"} <li> <a href="[field:typelink/]">[field:typename/]</a> <p>欄目描述:[field:description/]...</p> </li> {/dede:listsql} </ul> <h2>欄目分頁條</h2> <ul class="pagelist"> {dede:pagelist listitem="info,index,end,pre,next,pageno,option" listsize="5"/} </ul>
pagesize="10" 每頁顯示10個欄目
[field:typelink/] 欄目鏈接
[field:typename/] 欄目名稱
[field:其他字段/] 欄目其他自定義字段都可以直接調(diào)用
如果封面頻道也要作為最終列表欄目和分頁
參考這個這個文章,
版權(quán)聲明: 本站資源均來自互聯(lián)網(wǎng)或會員發(fā)布,如果侵犯了您的權(quán)益請與我們聯(lián)系,我們將在24小時內(nèi)刪除!謝謝!
轉(zhuǎn)載請注明: 織夢用欄目分頁來做小說站實現(xiàn)教程(支持動態(tài)靜態(tài))