Dedecms Template Tag Code official reference _php Tips

Source: Internet
Author: User
Tags tag name tagname
I didn't think Dedecms could do this DIY, ox.

Address: http://www.dedecms.com/archives/templethelp/help/
Before you know Dedecms's template code, it makes sense to understand the knowledge of a dream template engine. Dream-Weaving template engine is a template parser using the XML namespace form, the biggest benefit of parsing a template with a dream parser is that it makes it easy to make the attributes of the tag, feeling like you're using HTML, making the template code very intuitive and flexible, The new version of the Dream template engine can not only implement the template parsing can also be analyzed in the template error tags.

1, Dream template Engine code style has the following several 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 the {dede: Tag name attribute = ' value '}{/dede: Tag name} in this format, or you will get an error.

2. The Dream template engine has multiple system tags built into it, which can be used directly on any occasion.

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

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

(2) A 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 a Dede plate template (yes/no) '/}
Search paths for files are in order: Absolute path, include folder, CMS installation directory, CMS master template directory

3. Dream Mark allows a function to be used in any tag to process the resulting value in the form of:
{dede: Tag name attribute = ' value ' function= ' youfunction (parameter one, parameter two, @me) '/}
Where @me is used to represent the value of the current tag, and other parameters are determined by your function, such as:
{Dede:field name= ' pubdate ' function= ' strftime ('%y-%m-%d%h:%m:%s ', ' @me ') '/}

4. Dream-weaving marks allow limited programming extensions.
The format is:
{dede:tagname runphp= ' yes '}
$AAA = @me;
@me = "123456";
{/dede:tagname}
The @me represents the value of the tag itself, so that markup programming cannot use statements such as ECHO, and can only pass 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.

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.