Php. Template labeling system for MVC (i) _php tutorial

Source: Internet
Author: User
Tags html header
Php. The MVC template label system (PHPMVC_TAGS) now offers 3 types of tags: include directives, declarations, and expressions.
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 ' @>
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" @>
The expression label allows us to execute an expression in the template page. The result of the expression is 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.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 a view resource (template), and also to configure a template tagging system, It will be shown below. The view-resources element in the Phpmvc-config.xml configuration file is shown below:
AppTitle = "Flash jacks ' Sleek tab Site"
Copyright = "Copyright @" Flash Jack. All rights reserved. "
ContactInfo = "Flash.jack@jackshost.com"
Processtags = "true"
Compileall = "true"
ClassName = "Myviewresourcesconfig" >




Template page processing using a template tag system can be controlled by nodes. First we can define whether the template tag system compiles all template pages or compiles only the modified one. Second, we can define if the template label system really handles the label page, Working with label pages is useful in the application configuration and after configuration. The following cells show the Compileall and Processtags properties set to True (always process tabs and process all tabs):
<>
...
Processtags = "true"
Compileall = "true"
...



Action Dispatcher

Php. MVC version beta 0.4. More than 0 Actiondispatcher classes are used to make formbean,errors,value (business data) and Viewresourcesconfig objects available in our view (template).
We should take a quick look at the actionobjects and Viewresourcesconfig classes before checking the template labeling system when using standard Actiondispatcher.

Actionobjects

Actiondispatcher makes it possible for some objects to be available in application view resources in the template pages we use. The 3 standard actionobjects are: Formbean,errors, and value (business data) objects.
The table shows how the formbean,errors and value objects are used in the FormAction and 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

A actionobject will be initialized to null if the object was not 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 Templates page. Viewresourcesconfig objects are in the phpmvc-config.xml configuration file. element is configured. If the Viewresourcesconfig object is not configured yet, a new instance will use the properties of the default Viewresourcesconfig class.
The following code shows how an expression using the template label system accesses the Viewresourcesconfig property in our HTML header template:


<@ =viewconfig.getapptitle @>

Configure the Action Dispatcher

Actiondispatcher is the default PHP.MVC (in beta 0.4.0 or later) Dispatcher class. This action dispatcher is 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--tagactiondispatcher class.

http://www.bkjia.com/PHPjc/313711.html www.bkjia.com true http://www.bkjia.com/PHPjc/313711.html techarticle PHP. The MVC template label system (PHPMVC_TAGS) now offers 3 types of tags: include directives, declarations, and expressions. The include instruction allows us to separate the content into many modules, such as: header, footer ...

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