Thinkphp commonly used built-in tags include the detailed

Source: Internet
Author: User
http://www.php.cn/php/php-tp-historyoutput.html "target=" _blank "> variable output is sufficient to use normal tags, but to complete other control, loop and judgment functions, It is necessary to use the tag library function of the template engine, and all the tags of the system's built-in tag library can be used directly without introducing the tag library.

There are two types of XML tags, including closed tags and open tags, when a label is defined to determine whether it is a closed or open label, not mixed use, for example:

Closing Tags:

<include file= "read"/>

Open Tags:

<GT name= "Name" value= "5" >value</gt>

The list of supported tags and attributes is as follows:

Label Signature

Role

Include property

Include

Include external template file (closed)

File

Import

Import resource file (closed including JS CSS load alias)

File,href,type,value,basepath

Volist

Loop array Data output

Name,id,offset,length,key,mod

Foreach

Array or object traversal output

Name,item,key

For

For loop data output

Name,from,to,before,step

Switch

Branch judgment output

Name

Case

Branch judgment output (must be used with switch)

Value,break

Default

Default output (closed must be used with switch)

No

Compare

Compare outputs (including EQ NEQ lt gt egt Elt Heq Nheq aliases)

Name,value,type

Range

Range judgment output (including in notin between Notbetween aliases)

Name,value,type

Present

Determining whether to assign a value

Name

Notpresent

Determine if a value has not been assigned

Name

Empty

Determine if the data is empty

Name

Notempty

Determine if the data is not empty

Name

Defined

Determine if a constant is defined

Name

notdefined

To determine if a constant is undefined

Name

Define

Constant definition (closed)

Name,value

Assign

Variable assignment (closed)

Name,value

If

Conditional Judgment Output

Condition

ElseIf

Conditional judgment output (closed must be used with if label)

Condition

Else

The condition does not set up the output (closed can be used for other labels)

No

Php

Using PHP code

No

1.include

You can use the include tag to include external template files, using the following methods:

Include tags (including external template files)

Closed

Closed label

Property

File (required): template file to include, support variable

Example:

1. Use the full file name to include

Format:

<include file= "full template file name"/>

For example:

<include file= "./tpl/default/public/header.html"/>

In this case, the template file name must contain a suffix. When using the full file name, it is important to note that the file contains a server-side inclusion, not a URL address, that is, the file parameter is the server-side path, if you use a relative path, it is based on the entry file location of the project.

2. Other action template files containing the current module

Format:

<include file= "Operation name"/>

For example, import the Read action template under the current module:

<include file= "read"/>

The action template does not need to have a suffix.

3. Action template with other modules

Format:

<include file= "module name: Operation name"/>

For example, the header action template that contains the public module:

<include file= "Public:header"/>

4. Module action template with other template themes

Format:

<include file= "theme name: module Name: Action name"/>

For example, the Read action template for the user module that contains the blue theme:

<include file= "Blue:User:read"/>

5. Use variables to control the template to be imported

Format:

<include file= "$ variable name"/>

For example

<include file= "$tplName"/>

assigning different values to $tplname can contain different template files, and the values of the variables are used the same as the previous usage.

Regardless of the way you use the external template, the include tag supports passing in parameters at the same time as the include file, for example, in the following example we passed the title and keywords variables when we included the header template:

<include file= "header" title= "thinkphp framework" keywords= "open source Web development framework"/>

You can use the var1 and VAR2 variables in the included Header.html file, method


Note: Because of the characteristics of template parsing, parsing starts from the portal template, and if the external template changes, the template engine does not recompile the template unless in debug mode or the cache has expired. If the included external template file is modified in deployment mode, the cache directory of the module needs to be emptied, otherwise it will not take effect.

The above is thinkphp commonly used built-in tags include the detailed content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!

  • 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.