Php. MVC tag Syntax
After a basic introduction, we can now look at the syntax of the template tag system.
Before we look at specific tags, we should define what we label. To write a label, we use the <@ ... @> tag node. The left label (<@) and the right label (@>) are the default labels. If necessary, These tags can be redefined in phpmvc-config.xml.
The template label system now supports the following 3 types of tags: include directives, declarations, and expressions. Let's take a look at these instructions.
Include directives
The include directive allows us to separate content into many modules, such as headers, footers, or content. The included pages can be HTML, or other label template pages. For example, the following include directives can be used to include a header:
<@ include ' PAGEHEADER.SSP ' @>
An example that contains directives in the context of a template:
...
<@ include ' PAGEHEADER.SSP ' @>
|
... ...
...
Here is an example of a PAGEHEADER.SSP header file content that will be inserted into the main page and this page is sent to the user's browser. This header file contains an expression:
<@ =viewconfig.getapptitle @>
This expression will be compiled and will be output at run time as:
Flash Jacks ' Sleek Tab Site
Statement
A declaration allows us to declare a variable at a page level in a template, or even another containing page. A declaration looks like the following code:
<@ salesareaid = "Central District" @>
We are able to use the declaration in the template file:
<@ salemonth = Data.getvaluebean (' sale_month ') @>
<@ saletitle = Data.getvaluebean (' sale_title ') @>
<@ dealheading = Data.getvaluebean (' deal_heading ') @>
<@ salesareaid = "Central District" @>
<BR> ...<br>
...
In this example, we declare some page variables. The first 3 variables are already assigned in Actionobject in the action class we created: Data.getvaluebean (' Sale_month '). The 4th variable is assigned a string value: Salesareaid = "Central District".
The declared variables can now be used in the page:
...
<@=dealheading @> <@=salemonth @>
Clearance Deals
Todays Specials
...
These page variables will be output as:
Jack ' s Super Deals for:may 2010
...
...
An expression
The
Expression label allows us to execute an expression in a template page. The result of the expression will be included in the template page. The following expression will be used to display a simple string (salesareaid), or to retrieve the properties of the framework Configuration class:
<@ =salesareaid @
<@ =viewconfig.contactinfo @>
In order to use these expressions, we have previously declared:
<@ salesareaid = "Central District" @>
or the properties in the Viewresourcesconfig object (viewconfig) are declared in the view-resources node:
AppTitle = "Flash Jacks ' S Leek tab Site "
ContactInfo =" flash.jack@jackshost.com "
...
When using an object in an expression, we can write an object-method (Object-method) declaration in standard PHP notation or point-style notation:
The phpmvc_tags object-method Notation br>php Style sales = data->getsales
Dot Style sales = Data.getsales
with Method Params staff = Data.getva Luebean ("Staff")
Retrieve Data Array products = Data->getvaluebean ("Products_array")
in the next cell we will see how to use the template label The system combines these together to build the page.
http://www.bkjia.com/PHPjc/313704.html www.bkjia.com true http://www.bkjia.com/PHPjc/313704.html techarticle PHP. After a basic introduction to the MVC tag syntax, we can now look at the syntax of the template tag system. Before we look at specific tags, we should define what we label as our labels.