Home > Article > Backend Development > Introduction to Dreamweaver template tag_PHP tutorial
Before understanding the template code of DedeCms, it is very meaningful to understand the knowledge of the DreamWeaver template engine. The Dreamweaver template engine is a template parser that uses XML namespaces. 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. 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: 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 using with bottom layer The template tag must strictly use the format {dede:mark name attribute='value'}{/dede:mark name}, otherwise an error will be reported.
2. The DreamWeaver template engine has multiple built-in system tags, which can be used directly in any situation.
(1) global tag, which means to obtain an external variable. In addition to the database password, any configuration parameters of the system can be called. 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 the variable $cfg_cmspath, which 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 section 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 allows the use of functions in any tag to process the obtained value, in the form It is:
{dede: tag name attribute='value' function='youfunction("parameter one", "parameter two", "@me")'/}
where @me is used to represent the current The value of the 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:
{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. 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 need to be programmed can only use the default InnerText.