What is the DEDECMS static template class file?
What is the DEDECMS static template class file?
Static template class file Dreamweaver template engine is a template parser that uses XML namespace form
Recommended learning: Dreamweaver cms
The biggest advantage of using the Dreamweaver parser to parse templates is that you can easily specify the attributes of the tag. It feels like using HTML, making the template code very intuitive and flexible. The new version of the Dreamweaver template engine can not only realize the template Parsing can also analyze incorrect markup in templates.
include/dedetag.class.php This file is the main template class used by dedecms V5.3 and previous versions. It is an analytical template class, not a compiled one (the difference is that the former is performed by obtaining the tag position. Content replacement, the latter is directly parsed PHP code, executed twice)
1. Template syntax
1. The code styles of the Dreamweaver template engine have the following forms:
{dede:Tag name attribute='value'/}
{dede:Tag name attribute='value'}{/dede:Tag name}
{dede:Tag name Attribute = 'value'} Custom style template (InnerText) {/dede: tag name}
Tips:
If you use a tag with an underlying template, you must strictly use {dede: tag name Attribute='value'}{/dede:tag name} This format, otherwise an error will be reported.
2. The DreamWeaver template engine has multiple built-in system tags, and these system tags can be used directly in any situation.
(1) The global mark means to obtain an external variable. In addition to the database password, it can call any configuration parameters of the system. The form is:
{dede:global name='variable name '}{/dede:global}
or
{dede:global name='variable name'/}
The variable name cannot be added with the $ symbol, such as variable $ cfg_cmspath should be written as {dede:global name='cfg_cmspath'/}.
(2) foreach is used to output an array, in the form:
{dede:foreach array='array name'}[field:key/] [field:value/]{/ dede:foreach}
(3) include introduces a file in the form:
{dede:include file='file name' ismake='whether it is a dede plate template (yes/no) '/}
The search path for files is in the order: absolute path, include folder, CMS installation directory, CMS main template directory
3. The Dreamweaver tag is allowed to be used in any tag The function processes the obtained value in the form:
{dede: tag name attribute='value' function='youfunction("Parameter 1", "Parameter 2", "@me")' /}
Where @me is used to represent the value of the current tag, other parameters are determined by your function, for example:
{dede:field name='pubdate' function='strftime ("%Y-%m-%d %H:%M:%S","@me")'/}
4. The Dreamweaver mark allows limited programming expansion.
The format is:
The code is as follows:
{dede:tagname runphp='yes'} $aaa = @me; @me = "123456"; {/dede:tagname}
@me represents the value of the tag itself, so statements such as echo cannot be used in programming within the tag, only Pass all return values to @me.
In addition, because the program code occupies the content of the underlying template InnerText, the tags that require programming can only use the default InnerText.
2. Parsing method
There are four classes in dedetag.class.php
class DedeAttribute attribute structure expression
class DedeAttributeParse attribute parser
class DedeTag tag structure expression
class DedeTagParse tag parser
When using the parsing class to parse templates, the following steps are generally followed
1. Initialization:
$dtp = new DedeTagParse();
2. Load template/template string:
$dtp->LoadTemplate(template file (absolute path)); / / will generate a cache, and there is no need to parse the template the second time
or
$dtp->LoadSource(string);
3. Assign a value to the tag
foreach($dtp->CTags as $tid=>$ctag) {
//Determine the name and attributes of ctag, and assign different values, usually using functions
if($ctag->GetName=='mytag') $dtp->Assign($tid, mytagvalue($ctag) );
}
In the above example , directly transfer the tag named mytag to the mytagvalue function for processing. Mytagvalue determines each attribute of $ctag and returns different contents.
In the V5.3 version, usually in addition to special tags such as field and list, the tags of files parsed by classes starting with arc.* correspond to the source code of the include/taglib. This is determined by the system. Automatic mapping is performed.
4. Display or save as HTML
$dtp->display();
or
$dtp->SaveTo(static file name);
对于二次开发人员而言,不大需要知道dedecms模板具体解析方式,不过应该十分清楚CTag这个类的结构,从而判断标签不同属性进行处理。
代码如下:
class DedeTag { var $IsReplace=FALSE; //标记是否已被替代,供解析器使用 var $TagName=""; //标记名称 var $InnerText=""; //标记之间的文本 var $StartPos=0; //标记起始位置 var $EndPos=0; //标记结束位置 var $CAttribute=""; //标记属性描述,即是class DedeAttribute var $TagValue=""; //标记的值 var $TagID = 0; //获取标记的名称和值 function GetName() { return strtolower($this->TagName); } function GetValue() { return $this->TagValue; } //下面两个成员函数仅是为了兼容旧版 function GetTagName() { return strtolower($this->TagName); } function GetTagValue() { return $this->TagValue; } //获取标记的指定属性 function IsAttribute($str) { return $this->CAttribute->IsAttribute($str); } function GetAttribute($str) { return $this->CAttribute->GetAtt($str); } function GetAtt($str) { return $this->CAttribute->GetAtt($str); } function GetInnerText() { return $this->InnerText; } }
The above is the detailed content of What is the DEDECMS static template class file?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Empire CMS template download location: Official template download: https://www.phome.net/template/ Third-party template website: https://www.dedecms.com/diy/https://www.0978.com.cn /https://www.jiaocheng.com/Installation method: Download template Unzip template Upload template Select template

Template replacement can be implemented in Dedecms through the following steps: modify the global.cfg file and set the required language pack. Modify the taglib.inc.php hook file and add support for language suffix template files. Create a new template file with a language suffix and modify the required content. Clear Dedecms cache.

How to upload local videos using Dedecms? Prepare the video file in a format that is supported by Dedecms. Log in to the Dedecms management backend and create a new video category. Upload video files on the video management page, fill in the relevant information and select the video category. To embed a video while editing an article, enter the file name of the uploaded video and adjust its dimensions.

Dedecms is an open source CMS that can be used to create various types of websites, including: news websites, blogs, e-commerce websites, forums and community websites, educational websites, portals, other types of websites (such as corporate websites, personal websites, photo album websites, video sharing website)

Dedecms is an open source Chinese CMS system that provides content management, template system and security protection. The specific usage includes the following steps: 1. Install Dedecms. 2. Configure the database. 3. Log in to the management interface. 4. Create content. 5. Set up the template. 6. Manage users. 7. Maintain the system.

DedeCMS is an open source content management system that has some potential vulnerabilities and security risks: 1. SQL injection vulnerability. Attackers can perform unauthorized operations or obtain sensitive data by constructing malicious SQL query statements; 2. File Upload vulnerability, attackers can upload files containing malicious code to the server to execute arbitrary code or obtain server permissions; 3. Sensitive information leakage; 4. Unauthenticated vulnerability exploitation.

Accurate and reliable dedecms conversion tool evaluation report With the rapid development of the Internet era, website construction has become one of the necessary tools for many companies and individuals. In website construction, using a content management system (CMS) can manage website content and functions more conveniently and efficiently. Among them, dedecms, as a well-known CMS system, is widely used in various website construction projects. However, sometimes we are faced with the need to convert the dedecms website to other formats, in which case we need to use a conversion tool

Learning dedecms encoding conversion function is not complicated. Simple code examples can help you quickly master this skill. In dedecms, the encoding conversion function is usually used to deal with problems such as Chinese garbled characters and special characters to ensure the normal operation of the system and the accuracy of data. The following will introduce in detail how to use the encoding conversion function of dedecms, allowing you to easily cope with various encoding-related needs. 1.UTF-8 to GBK In dedecms, if you need to convert UTF-8 encoded string to G
