PHP. MVC template tag system (3)

Source: Internet
Author: User
PHP. MVC template tag system (3) PHP. MVC tag syntax

After the basic introduction, we can now look at the syntax of the template tag system.
Before looking at the specific tag, we should define what serves as our tag. to write a tag, we use <@... @> tag node. the left tag (<@) and right tag (@>) are default labels. if necessary, these labels can be redefined in phpmvc-config.xml.
The template tag system now supports the following three types of labels: including commands, declarations, and expressions. let's take a look at these commands.

Include commands

The include command separates content into many modules, such as the header, footer, or content. the contained page can be HTML or other tag template pages. for example, the following include command can be used to contain a header:
<@ Include 'pageheader. SS' @>
An example of a template context containing commands:


... ...

<@ Include 'pageheader. SS' @>


In this example, the content of the pageHeader. ssp header file will be inserted on the home page and sent to the user's browser. this header file contains an expression:

<@ = ViewConfig. getAppTitle @>

This expression will be compiled and output at runtime as follows:

Flash Jacks 'sleek Tab Site


The declaration allows us to declare a page-level variable in the template, or even other include pages. a declaration looks like the following code:
<@ SalesAreaID = "Central District" @>
We can use the declaration in the template file:
<@ SaleMonth = data. getValueBean ('sale _ month') @>
<@ SaleTitle = data. getValueBean ('sale _ title') @>
<@ DealHeading = data. getValueBean ('dest_heading ') @>
<@ SalesAreaID = "Central District" @>

<BR>... <BR>


In this example, we declare some page variables. the first three variables have been assigned a value in the ActionObject of the Action class we created: data. getValueBean ('sale _ month '). the first variable is assigned a string value: salesAreaID = "Central District ".
The declared variables can now be used on the page:


<@ = DealHeading @> <@ = saleMonth @>

Clearance deals


Todays specials



These page variables will be output:

Jack's Super Deals for: May 2010


Expression tags allow us to execute expressions on the template page. the expression result is included in the template page. the following expression is used to display a simple string (salesAreaID). You can also retrieve the attributes of the framework configuration class:
<@ = SalesAreaID @>
<@ = ViewConfig. contactInfo @>
To use these expressions, we have to declare them before:
<@ SalesAreaID = "Central District" @>
You can also declare the attributes of the ViewResourcesConfig object in the view-resources node:
AppTitle = "Flash Jacks 'sleek Tab Site"
ContactInfo = ""

When using an object in an expression, we can write an object-method to declare a standard PHP or dot-style symbol:
The PhpMVC_Tags Object-Method Notation
PHP Style sales = data-> getSales
Dot Style sales = data. getSales
With Method Params staff = data. getValueBean ("STAFF ")
Retrieve Data Array products = data-> getValueBean ("PRODUCTS_ARRAY ")
In the next unit, we will see how to use the template tag system to combine these to build the page.

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