PHP.MVC Template Label System (i) _php Foundation

Source: Internet
Author: User
Tags html header
Php. The MVC template tagging system (Phpmvc_tags) now offers 3 types of tags: include directives, declarations, and expressions.
The include directive allows us to separate content into modules, such as headers, footers, or content. Included pages can be HTML, or other label template pages. For example, the following include instructions can be used to include a header:
<@ include ' PAGEHEADER.SSP ' @>
The declaration allows us to declare a page-level variable in the template species, or even other included pages. A declaration looks like the following code:
<@ salesareaid = "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. The MVC Beta 0.4.0 introduced a new configuration class called Viewresourcesconfig. This class can be used to define global parameters that can be used in view resources (templates) and also to configure the template tagging system. It will display the following in the. Phpmvc-config.xml configuration file, the View-resources element is shown below:
<view-resources
AppTitle = "Flash jacks ' Sleek tab Site"
Copyright = "Copyright @ Flash Jack." All rights reserved. "
ContactInfo = "Flash.jack@jackshost.com"
Processtags = "true"
Compileall = "true"
ClassName = "Myviewresourcesconfig" >

       <!--We can set some properties on our custom Viewresourcesconfig class & nbsp;     
       <set-property property= " Areamanager "Value=" Joe J. Blogs Esq. "/>
    </view-resources>
    Template page processing using a template tag system can be controlled by <view-resources> nodes. First we can define whether the template tag system compiles all the template pages or only compiles the modified one. Secondly, we can define if the template tag system really wants to process the tag page, Processing tag pages is useful in the application configuration and after configuration. The <view-resources> shown in the following unit is to set the Compileall and Processtags properties to true (always process the label page and process all the tab pages):
    <view-resources
   ...
   processtags = "true"
   compileall  = "true"
   ...
    </view-resources>

Action Dispatcher

Php. The MVC version of beta 0.4.0 Actiondispatcher class is used to make 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 standard Actiondispatcher.

Actionobjects

Actiondispatcher makes some objects available in the Application view resource in the template page we use. The 3 standard actionobjects are: Formbean,errors, and value (business data) objects.
The table shows how to use the Formbean,errors and value objects 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 created and saved before. For more information about 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 page. Viewresourcesconfig objects are phpmvc-config.xml in the configuration file < The view-resources> element is configured. If the Viewresourcesconfig object has not been configured, 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 an expression that uses the template label system:
<!--Page Header-->
<span>
<@ =viewconfig.getapptitle @>
</span>

Configure Action Dispatcher

Actiondispatcher is the default PHP.MVC (in beta 0.4.0) 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'll see how to configure our application to use an alternative class--tagactiondispatcher class.

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.