GetName()=="specnote"){}"; then define the "$pecrule" variable ."/> GetName()=="specnote"){}"; then define the "$pecrule" variable .">
Home > Article > CMS Tutorial > How to use dedecms special template
How to use dedecms special template?
There is relatively little information on the topic of DeDeCms on bbs. I have consulted a lot of information before but could not find its solution
Recommended study: woven Dream cms
Wunai can only rely on his own efforts to make enough food and clothing; there is this passage in the official version:
1. The article list is separated in the form of ID1, ID2, ID3. The system will automatically exclude the same articles from different nodes;
2. Regarding the use of the [field:fieldname /] tag in a single record template, please refer to the description of the arclist tag in the system help;
3. Node ID is the unique identifier of the node. It is allowed to use {dede:specnote id='identity'/} to represent a single node in the topic template.
4. Under normal circumstances, each node displays the documents in the "Node Article List". If you specify "automatic acquisition mode", you must specify the keyword and column ID.
However, after testing {dede:specnote id='note'/} this did not improve the efficiency; so we started to solve this problem to replace the original more rigid {dede:field name='note'/} tag;
Example:
I want to display articles with different nodes in two columns. Currently, it cannot be achieved using "note". It can only be divided into columns for the same node, which inevitably seems a bit awkward. Not flexible enough.
Below I will write down my solution for students’ reference. First of all, I have to make it clear that it can only achieve the function, but the algorithm is not necessarily the best, because I am not very familiar with DEDECMS code and do not have I have studied it carefully and hope everyone will understand!
Step 1:
File location: {include/inc_archives_view.php}
The code is as follows:
//广告标记 //----------------------- 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"))); }
Introduction:{Add a topic under the advertising tag Mark} so that the special article list page can recognize the specnote tag
Step 2:
File location: {include/inc_channel_unit.php}
var $specrule; //------------- //php5构造函数 //-------------
Introduction: Added Definition of $pecrule variable
Step 3:
File location:{include/inc_channel_unit.php}
The code is as follows:
else if($ftype=="specialtopic"){ $this->specrule = $fvalue; $fvalue = $this->GetSpecList($fname,$fvalue); }
Introduction: Add here Add the sentence $this->specrule = $fvalue; in order to obtain the note field data of the addonspec table;
Step 4:
File location: {include/inc_channel_unit.php}
The code is as follows:
//获得专题文章的列表 //-------------------------------- 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; }
Introduction: There are some small changes, you will see them clearly by comparing them yourself, so I won’t shiver anymore
Step 5:
Instructions: The original {dede:field name='note'/} tag is invalid. If you want to use it, please modify the fourth part by yourself. .
Very simple;
Done!
The above is the detailed content of How to use dedecms special template. For more information, please follow other related articles on the PHP Chinese website!