First of all, let’s introduce the DreamWeaver template engine.
(Learning video sharing: Programming video)
The Dreamweaver template engine is a template parser that uses XML namespace form. Use the Dreamweaver parser to parse templates. The biggest advantage is that you can easily specify the attributes of the tags, which feels like using HTML, making the template code very intuitive and flexible. The new version of the Dreamweaver template engine can not only parse the template but also analyze the wrong tags in the template.
1. The code styles of the Dreamweaver template engine have the following forms:
{dede:标记名称 属性='值'/} {dede:标记名称 属性='值'}{/dede:标记名称} {dede:标记名称 属性='值'}自定义样式模板(InnerText){/dede:标记名称}
Tips:
If you use a tag with an underlying template, you must strictly use {dede: tag name attribute ='value'}{/dede:mark 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) global tag, indicating to obtain an external variable, in addition to the database password, can call any configuration parameters of the system, in the form:
{dede:global name='变量名称'}{/dede:global}
or
{dede:global name='变量名称'/}
The $ symbol cannot be added to the variable name. For example, the 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='数组名称'}[field:key/] [field:value/]{/dede:foreach}
(3) include introduces a file, in the form:
{dede:include file='File name' ismake='Is it a dede plate template (yes/no)'/}
The search path for files is in order: absolute path, include folder, CMS installation directory, CMS main template directory
3. The Dreamweaver tag allows the use of functions in any tag to process 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 whether they exist, 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:
{dede:tagname runphp='yes'} $aaa = @me; @me = "123456"; {/dede:tagname}
@me represents the value of the tag itself. Therefore, statements such as echo cannot be used in programming within the tag. All return values can only be passed to @me.
In addition, since the program code occupies the content of the underlying template InnerText, the tags that require programming can only use the default InnerText.
Related recommendations: dedecms tutorial
The above is the detailed content of Related introduction to dedecms template engine. For more information, please follow other related articles on the PHP Chinese website!