Home > CMS Tutorial > DEDECMS > body text

How to use dedecms special template

藏色散人
Release: 2020-01-13 09:38:20
Original
2787 people have browsed it

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")));
}
Copy after login

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构造函数
//-------------
Copy after login

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); 
}
Copy after login

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;
}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!