Home> php教程> PHP开发> body text

PHP.MVC template tag system (1)

黄舟
Release: 2016-12-17 10:04:29
Original
1021 people have browsed it

php.MVC’s template tag system (PhpMVC_Tags) now provides 3 types of tags: include directives, declarations and expressions.
Include directives allow us to separate content into many modules, such as: header, footer or content The included page can be HTML, or other tag template pages. For example, the following include directive can be used to include a page header:
<@ include 'pageHeader.ssp' @>
The declaration allows us to include Declare a variable at the page level, or even other containing pages. A declaration would look like the following code:
<@ salesAreaID = "Central District" @>
The expression tag allows us to perform expressions in the template page. Expressions The results will be included in the template page. The following expression will be used to display a simple string (salesAreaID), and can also retrieve the properties of the framework configuration class:
<@ =salesAreaID @>
<@ = viewConfig.getAreaManager @>
PHP.MVC beta 0.4.0 introduces a new configuration class called ViewResourcesConfig. This class can be used to define global parameters that can be used in VIEW resources (templates), and can also configure templates Tag system, it will be displayed below. The view-resources element in the .phpmvc-config.xml configuration file is displayed below:
aPPTitle = "Flash Jacks' Sleek Tab Site"
copyright = "Copyright @ 2010 Flash Jack. All rights reserved."
contactInfo = "flash.jack@jackshost.com" PRocessTags = "true" compileAll = -- We can SET SOME Properties on Our Custom ViewResourceSconfig Class-& GT;
& LT; SET-PROPERTY = "Areamanager" Value = "Joe J. Blogs ESQ."/& GT; & Lt;/view-resources & gt;
template page processing use template The tag system can be controlled by the node. First, we can define whether the template tag system compiles all template pages or only modified ones. Second, we can define whether the template tag system actually needs to process tag pages, Processing tags is useful during and after application configuration. The unit shown below has the compileAll and processTags properties set to true (always process tags and process all tags):
...

processTags = "true"
compileAll = "true"
...


Action Dispatcher

PHP.MVC version beta 0.4.0 or above ActionDispatcher class is responsible for Make the FormBean, Errors, Value (business data) and ViewResourcesConfig objects available in our VIEW (template).
Before checking the template tag system we should take a quick look at the ActionObjects and ViewResourcesConfig classes when using the standard ActionDispatcher.

ActionObjects

ActionDispatcher makes some objects available in the application VIEW resources in the template page we use. The three standard ActionObjects are: FormBean, Errors, and Value (business data) objects.

The following table shows the functions in FormAction How to use FormBean, Errors and Value objects in Action classes:
Saving ActionObjects in ActionForm Classes

ActionErrors $this->saveErrors($request, $actionErrors)

FormBeans $this->saveFormBean($request, $this)

ValueObjects $this->saveValueObject($request, $valueObject)


Saving ActionObjects in Action Classes
ActionErrors $this->saveErrors($request, $actionErrors)
FormBeans $this->saveFormBean($request, $form )
ValueObjects $this->saveValueObject($request, $valueObject)

Retrieving ActionObjects in View Resources (Templates)

ActionErrors $errors->getItemString('logon_username_reqd')
FormBeans $form->username
ValueObjects $ data->salesNorth

An ActionObject will be initialized to NULL if the object has not been previously created and saved. For more information on ActionObjects see here: http://www.phpmvc.net/docs/guides/guidesIdx.php?doc=action- objects

View Resources

ActionDispatcher can also expose ViewResourcesConfig objects to our template pages. The ViewResourcesConfig object is configured by the element in the phpmvc-config.xml configuration file. If the ViewResourcesConfig object has not been configured yet , then a new instance will use the properties of the default ViewResourcesConfig class.
The following code shows how to access the ViewResourcesConfig property in our HTML header template using expressions from the template tag system:
Class. The Action Dispatcher included in the framework will be used by default unless we define a class to replace the Dispatcher class. In the next section we will see how to configure our application to use an alternative class - the TagActionDispatcher class.

The above is the content of PHP.MVC’s template tag system (1). For more related articles, please pay attention to the PHP Chinese website (m.sbmmt.com)!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!