Introduction to Zhimeng template tag _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
Description of the Weaver dream template tag. Before learning about the template code of DedeCms, it is very meaningful to know about the Zhimeng template engine. The Zhimeng template engine is a template parser that uses the XML namespace form. it makes sense to understand the Zhimeng template engine knowledge before learning about the template code of DedeCms. The Zhimeng template engine is a template parser that uses XML namespaces. The biggest advantage of using the Zhimeng parser to parse templates is that you can easily define tag attributes, like using HTML, the template code is very intuitive and flexible. The new Zhimeng template engine can not only parse templates, but also analyze error tags in templates.

1. the code style of the Zhimeng template engine is as follows:
{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}

Tip:
If you use tags with underlying templates, you must strictly use the format {dede: Tag name attribute = 'value'} {/dede: Tag name}. Otherwise, an error is reported.

2. the Zhimeng template engine has multiple built-in system tags that can be directly used in any scenario.

(1) The global flag indicates obtaining an external variable. in addition to the database password, it can call any configuration parameters of the system in the form:
{Dede: global name = 'variable name'} {/dede: global}
Or
{Dede: global name = 'variable name '/}

The variable name cannot contain the $ symbol. for example, the variable $ inclu_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 template (yes/no )'/}
The search paths for files are in the absolute path, include folder, CMS installation directory, and CMS Main Template directory.

3. the woven dream mark allows the function to process the obtained value in any tag, in the form:
{Dede: Tag name attribute = 'value' function = 'youfunction ("parameter 1", "parameter 2", "@ me ")'/}
@ Me indicates 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. Weaver dream tags allow limited programming extensions.
Format:
{Dede: tagname runphp = 'yes '}
$ Aaa = @ me;
@ Me = "123456 ";
{/Dede: tagname}
@ Me indicates the value of this tag. Therefore, in-tag programming, echo and other statements cannot be used, and all return values can only be passed to @ me.
In addition, because the program code occupies the content of the underlying template InnerText, you must use the default InnerText only for the markup that needs to be programmed.

Bytes. The Zhimeng template engine is a template parser in the form of an XML namespace...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.