Home  >  Article  >  CMS Tutorial  >  DedeCMS template tag syntax

DedeCMS template tag syntax

(*-*)浩
(*-*)浩Original
2019-11-20 15:47:382478browse

DedeCMS template tag syntax

Dreamweaver's template tags are similar to XML format. All templates contain delimiters. By default, they are {dede:*} and {/dede:*}. , "*" represents the template tag name.

Generally {dede:*} and {/dede:*} appear in pairs, for example:                                                                                                                                                                                               ##Example 1-1:

{dede:arclist flag='h' limit='0,1'}
<h2><a href="[field:arcurl/]">[field:title/]</a></h2>
<p>[field:description/]...<a href="[field:arcurl/]">[查看全文]</a></p>
{/dede:arclist}
The above {dede:arclist} and {/dede:arclist} appear in pairs in the template file and are among the two tags Contains the underlying template (innertext).

Underlying template (Innertext), the underlying template is actually a template output for multiple records, and the user manually specifies the style of a single record. The

tag also appears in the form {dede:*/}, which usually appears as output variables or content that does not contain the underlying template.

For example: 1-2

{dede:global.cfg_webname/}
{dede:arclist flag=&#39;h&#39; limit=&#39;0,1&#39;/}
If the user does not specify the style of a single record, some tags in the system contain default underlying templates. For details, see {cmapath}/ The files under the templets/system/ folder contain the underlying template files of the system.

Comments

The template comments of the Dreamweaver tag are very flexible and can be assigned values ​​through the commet attribute behind the tag.

Example 1-3:

{dede:arclist flag=&#39;h&#39; limit=&#39;0,1&#39; commet=&#39;调用头条的第一篇内容&#39;}
<h2><a href="[field:arcurl commet="这是文章链接标签"/]">[field:titlecommet="这是文章标题标签"/]</a></h2>
<p>[field:description commet="这是摘要标签"/]...<a href="[field:arcurl  commet="这是文章链接标签"/]">[查看全文]</a></p>
{/dede:arclist}
When the template engine parses the above tags into html, the content of commet is ignored and not parsed. The user You can better understand the meaning of tags when reading template tags.

Function

Each DreamWeaver tag can be expanded using a custom function. The content of the custom function is mainly used to process the output content of the current tag. .

Example 1-4:

{dede:标记名称function=&#39;youfunction("参数一","参数二","@me")&#39;/}
where @me is used to represent the value of the current tag, and other parameters are determined by your function, for example:
{dede:field.pubdate function=&#39;strftime("%Y-%m-%d %H:%M:%S","@me")&#39;/}

Attribute

The attributes of the template tag determine the form of the template tag output. For example, the main function of the arclist tag is to list the document list, but what content is listed? The sorting method depends on the properties of the template tag.

The tag attributes of each template can be viewed in detail in the template tag description of DreamWeaver.

You can check flag='h' limit='0,1' in Example 1-1. Here flag and limit are the related attributes of the label. You can check the introduction of the attributes through the manual.

If the template tag does not list attributes, the system has default attribute values. Users can refer to the template tag description to view the default attributes.

Programming

One of the convenient aspects of Dreamweaver template is that it supports simple template programming.

The format is:

{dede:tagname runphp=&#39;yes&#39;}
$aaa = @me;
@me = "123456";
{/dede:tagname}
@me represents the value of the tag itself, so programming within the tag cannot use statements such as echo, and can only return all The value is passed to @me.

In addition, because the program code occupies the content of the underlying template InnerText, the tags that need to be programmed can only use the default InnerText.

The above is the detailed content of DedeCMS template tag syntax. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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