Introduction to the _php template tag tutorial

Source: Internet
Author: User
Tags tag name
Before you know the template code for DEDECMS, it makes sense to know the knowledge of the dream templating engine. Weaving dream template engine is a template parser using XML namespace form, the biggest advantage of using the Dream Parser parsing template is that it can easily make the attributes of the tag, it feels like HTML, so that the template code is very intuitive and flexible, The new version of the Weaving Dream template engine not only enables the parsing of templates but also analyzes the errors in the template.

1, Weaving Dream template Engine Code style has 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 the underlying template, you must strictly use {dede: Tag name attribute = ' value '}{/dede: Tag name} in this format, otherwise you will get an error.

2, weaving Dream template engine built-in multiple system tags, these system markings can be used in any situation directly.

(1) Global tag, which means to get an external variable, in addition to the database password, can invoke any configuration parameters of the system, in the form of:
{dede:global name= ' variable name '} {/dede:global}
Or
{dede:global name= ' variable name '/}

Where variable names cannot be added to the $ symbol, such as variables $cfg _cmspath, should be written as {Dede:global name= ' Cfg_cmspath '/}.

(2) foreach is used to output an array in the form of:
{dede:foreach array= ' array name '} [field:key/] [field:value/] {/dede:foreach}

(3) include introduces a file in the form of:
{dede:include file= ' file name ' ismake= ' is Dede plate template (yes/no) '/}
The search path to the file is in order: Absolute path, include folder, CMS installation directory, CMS master template directory

3. The dream tag allows a function to be used in any tag to process the resulting value, in the form:
{dede: Tag name attribute = ' value ' function= ' youfunction ("parameter One", "parameter Two", "@me") '/}
Where @me is used to represent the value of the current tag, other parameters are determined by your function for existence, for example:
{Dede:field name= ' pubdate ' function= ' strftime ("%y-%m-%d%h:%m:%s", "@me") '/}

4. Dream Weaving tags allow limited programming extensions.
The format is:
{dede:tagname runphp= ' yes '}
$AAA = @me;
@me = "123456";
{/dede:tagname}
@me represents the value of the tag itself, so in-markup programming is not possible with statements such as ECHO, only passing all return values to @me.
In addition, because the program code occupies the content of the underlying template innertext, the markup that needs to be programmed can only use the default innertext.

http://www.bkjia.com/PHPjc/318025.html www.bkjia.com true http://www.bkjia.com/PHPjc/318025.html techarticle before you know the template code for DEDECMS, it makes sense to know the knowledge of the dream templating engine. Dream Weaving template engine is a template parser using XML namespaces, using ...

  • Related Article

    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.