国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > 建站經驗 > 正文

dedecms專題模板應用分析及解決方案

2024-04-25 20:51:11
字體:
來源:轉載
供稿:網友

 DeDeCms的專題相關信息bbs上相對較少,之前查閱了很多資料都未找到其解決方案。無柰只有靠自己動手豐衣足食;在官方的版本上有這樣的一段話:

1、文章列表用ID1,ID2,ID3這樣形式分開,系統會自動排除不同節點的相同文章;

2、關于單條記錄模板里的[field:fieldname /]標記的使用,請參考關于系統幫助關于 arclist 標記的說明;

3、節點ID是節點的唯一標識,允許在專題模板中用{dede:specnote id='標識'/}這樣來表示單個節點。

4、正常的情況下,每個節點顯示的是“節點文章列表”里的文檔,如果你指定為“自動獲取模式”,那么必須指定關鍵字和欄目ID。

可是經測試{dede:specnote id='標識'/}這個并沒有升效;因此開始解決這個,以替換掉原來比較死板{dede:field name='note'/}標簽;

舉例說明:

我要分兩欄顯示不同節點的文章,目前用"note"就不能實現,只能是同一節點分欄,難免就顯得有些捌扭,不夠靈活。

下面我就把自己解決方案寫下供同學們參考,首先得申明一點,只能是實現了功能,可算法不一定是最好的,因為我不太熟悉DEDECMS代碼且沒有認真的研究過,希望大家海涵!

步驟1:

文件位置:{include/inc_archives_view.php}

代碼如下:

//廣告標記
//-----------------------
else if($ctag->GetName()=="myad"){
$this->dtp->Assign($tagid,$this->PartView->GetMyAd($typeid,$ctag->GetAtt("name")));
}
// 專題標識
// by phpfans
else if($ctag->GetName()=="specnote"){
$this->dtp->Assign($tagid,$this->ChannelUnit->GetSpecList('',$this->ChannelUnit->specrule,$ctag->GetAtt("id")));
}

 

介紹:{在廣告標記下增加專題標識}這樣專題文章列表頁就可以識別specnote標簽了

步驟2:

文件位置:{include/inc_channel_unit.php}

var $specrule;

//-------------

//php5構造函數

//-------------

介紹:增加了對$pecrule變量的定義

步驟3:

文件位置:{include/inc_channel_unit.php}

代碼如下:

else if($ftype=="specialtopic"){
$this->specrule = $fvalue;
$fvalue = $this->GetSpecList($fname,$fvalue); 
}

介紹:這兒增加了$this->specrule = $fvalue;這句,以便獲取addonspec表的note字段數據;

步驟4:

文件位置:{include/inc_channel_unit.php}

代碼如下:

//獲得專題文章的列表
//--------------------------------
function GetSpecList($fname,$noteinfo,$noteid="")
{
if(!isset($GLOBALS['__SpGetArcList'])) require_once(dirname(__FILE__)."/inc/inc_fun_SpGetArcList.php");
if($noteinfo=="") return "";
$rvalue = "";
$tempStr = GetSysTemplets("channel/channel_spec_note.htm");
$dtp = new DedeTagParse(); </p> <p></p> <p>$dtp->LoadSource($noteinfo);
if(is_array($dtp->CTags))
{
foreach($dtp->CTags as $k=>$ctag){
$notename = $ctag->GetAtt("name");
if($noteid!="" && $ctag->GetAtt("noteid")!=$noteid){ continue; } //指定名稱的專題節點
if($noteid!="" && $ctag->GetAtt("noteid")===$noteid) {
$isauto = $ctag->GetAtt("isauto");
$idlist = trim($ctag->GetAtt("idlist"));
$rownum = trim($ctag->GetAtt("rownum"));
if(empty($rownum)) $rownum = 40;
$keywords = "";
$stypeid = 0;</p> <p>if($isauto==1){
$idlist = "";
$keywords = trim($ctag->GetAtt("keywords"));
$stypeid = $ctag->GetAtt("typeid");
}</p> <p>if(trim($ctag->GetInnerText())!="") $listTemplet = $ctag->GetInnerText();
else $listTemplet = GetSysTemplets("spec_arclist.htm");
$idvalue = SpGetArcList($this->dsql,
$stypeid,$rownum,$ctag->GetAtt("col"),
$ctag->GetAtt("titlelen"),$ctag->GetAtt("infolen"),
$ctag->GetAtt("imgwidth"),$ctag->GetAtt("imgheight"),
"all","default",$keywords,$listTemplet,100,0,$idlist);</p> <p>$notestr = str_replace("~notename~",$notename,$tempStr);
$notestr = str_replace("~spec_arclist~",$idvalue,$notestr);
$rvalue .= $notestr;
if($noteid!="" && $ctag->GetAtt("noteid")==$noteid){ break; }
}
}
}
$dtp->Clear();
return $rvalue;
}

介紹:有些小改動,自己對比一下就清楚了,這兒就不再哆嗦了

步驟5:

說明: 原{dede:field name='note'/}標簽失效了,如果要用的朋友請自行修改步驟四部份。。

很簡單的;完工!


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 老河口市| 牙克石市| 靖江市| 德州市| 开原市| 浪卡子县| 白朗县| 乐清市| 马鞍山市| 阿坝县| 刚察县| 延庆县| 滨海县| 九寨沟县| 夏津县| 教育| 金堂县| 象山县| 佛冈县| 镇赉县| 纳雍县| 鄂州市| 邵武市| 托克托县| 萨嘎县| 赞皇县| 邳州市| 桃江县| 五家渠市| 宁阳县| 团风县| 沂源县| 宜良县| 田阳县| 奉新县| 吴堡县| 健康| 邮箱| 湘潭县| 清远市| 福清市|