Page Layout
In this unit we will see how to use the template tag system to construct a standard template page. For this example we use a simple HTML page layout, please see the picture below:
This page is composed of multiple standard units, just like page designers and developers are familiar with. The main body of this page consists of 3 It consists of units: header, page content body and footer. We will now look at these units and understand how to use the template tag system to implement.
Page Body
The following code unit displays the body:
The Page Body Layout
1
3
'>
' '
1: Page Declaration
The first interesting entry is the page declaration (1) at the top of the page. We declare these variables at the beginning of the page, so these variables will be available in the page below and in the containing page like the header. .
2: Page title
Next we use an expression to initialize the page title (2). This value can be obtained from the view-resources element in the configuration file using ViewResourcesConfig->getAppTitle:
...
3: Header
The header is the next interesting entry (3). Here we use the include directive to insert the header template file Go to the page body. We will take a look at the header in the next sub-unit.
We just used the page to read the header directly, regardless of where the page components are stored. This is a good opportunity to introduce the template tag system Directory settings. By default, the template directory layout looks like this (note these paths are relative to our application):
The Default phpMVC_Tags Template Directory Layout Paths (relative)
The Template Files './WEB-INF/tpl'
The Compiled Template Files './WEB-INF/tpl_C'
If necessary we can redefine them in the view-resources node of the configuration file, like this:
tplDir = "./WEB-INF/tpl-admin"
tplDirC = "./WEB-INF/tpl_admin_C"
...
4: Page content body
This is another containing directive Used to insert template files (4) into the body. Note that the included files are located in the sales subdirectory of the template directory:
"./WEB-INF/tpl/sale/pageContent.ssp"
5: Footer
Another one Contains directives, just like a page header.
Header unit
In this example the header template file ('pageHeader.ssp') is just a simple unit, like this:
getAppTitle(); ?>
The compiled page is stored in In the compiled template directory, as mentioned above, the default compiled template directory is:
'./WEB-INF/tpl_C'
Page content main unit
The page content main template file is a bit complicated. File ('sale /pageContent.ssp') content is displayed as follows:
...1
getValueBean("ITEM_1") @>
getValueBean("PRODUCTS_ARRAY" ) @>
2
3
ue' > class ='productsTable'>
Our Staff at Your Service
...
5
Area Manager: |
|
$saleTitle = "Flash Jack's Super Sale";
$ dealHeading = "Jack's Super Deals for: ";
AddValueBean saleMonth);
$valueBeans->addValueBean('SALE_TITLE' , $saleTitle);
$valueBeans->addValueBean('DEAL_HEADING' , $dealHeading);
...
we could receive from a database query
//note: The Product Class File WAS Included in Our Local Prepend.php File
$ ITEM1 = New PRODUCT ('Super Duper', $ PRI CE1); ('ITEM_1', $item1);
:...
// Save the Value object
saveValueObject($request, $ $valueBeans); $item1 Now it can be retrieved in the template page:
getValueBean("ITEM_1") @>
We can display the value of the item like this:
Footer unit
The footer unit is handled similarly to the header unit discussed above. The footer template file ('tpl/pageFooter.ssp') looks like this:
When the main page (including included pages) is compiled, the expression in the footer is converted to the following:
getCopyright(); ?>
The compiled header page is stored in the compiled template directory. Default The compiled template directory is:
'./WEB-INF/tpl_C'
The above is the content of PHP.MVC's template tag system (4). For more related articles, please pay attention to the PHP Chinese website (www.php.cn)!