PHP. MVC template tag system (5). read PHP. MVC template tag system (5). only a few steps are required to create a template tag system application. note: The following procedure assumes that a new SleeK example application is used (this example can be found at www.phpmvc.net ). modify the boot. ini file application boo "> <LINKhr
Create a template tag system application
Only a few steps are required to create a template tag system application.
Note: The following procedure assumes that a new SleeK example application is used (this example can be found in ).
Modify the boot. ini file of the application
Application boot. the INI file must contain PHP. MVC framework information. boot. the INI file is typically located under the "WEB-INF" Directory of the application. to set the application to use the template label class, we need. the INI file defines some attributes.
TagActionDispatcher class
TagActionDispatcher is the standard implementation of the ActionDispatcher class. to enable the framework to read the TagActionDispatcher class, we set the value of $ appServerRootDir to 'tagactiondispatcher ':
// Setup the application specific ActionDispatcher (RequestDispatcher)
$ ActionDispatcher = 'tagactiondispatcher ';
Template tag system database root directory
We also need to set the path to point to our PHP. MVC Library (the absolute path of the file system is required ):
// Set php. MVC library root directory (no trailing slash ).
$ AppServerRootDir = 'C: \ WWW \ phpmvc-base ';
Optional
You can use the $ timerRun attribute to enable or disable an application timer:
// Timer reporting. 1 = on, 0 = off
$ TimerRun = 1;
You can also guide the framework to always (forcibly) compile the application phpmvc-config.xml configuration class (preferably in the development phase, because it will be slow), we use:
// The application XML configuration data set:
$ AppXmlCfgs = array ();
$ AppXmlCfgs ['config'] = array ('name' => 'phpmvc-config. XML', 'FC' => True );
Or recompile the application configuration file only when the phpmvc-config.xml file is modified (use this setting after development is complete, fast), we use:
// The application XML configuration data set:
$ AppXmlCfgs = array ();
$ AppXmlCfgs ['config'] = array ('name' => 'phpmvc-config. XML', 'FC' => False );
Set the application Template directory
When setting the template directory for the template tag application, we need to create a directory (and sub-directory) and place our application template file. this directory must be named as the value defined by the $ tplDir attribute of the View resource configuration class. the default value is '. /WEB-INF/tpl '. for example, the example application has a template directory structure set like this:
-PhpMVC-Tags
Index.html
Main. php
WEB-INF
Tpl
PageFooter. ssp
PageHeader. ssp
SalePageBody. ssp
Sale
PageContent. ssp
We also need to create a directory to place the compiled page. this directory must be named as the value defined by the $ tplDirC attribute of the View resource configuration class. the default value is '. /WEB-INF/tpl_C '. the example application has a template directory structure set like this:
PhpMVC-Tags
Index.html
Main. php
WEB-INF
Tpl
...
Sale
...
Tpl_C
PageFooter. sspC
PageHeader. sspC
SalePageBody. sspC
Sale
PageContent. sspC
Note that we also need to create the sale directory under './WEB-INF/tpl_C.
Set the path and inclusion of the PHP. MVC Library
Check that the following path settings have been defined in the GlobalPaths. php and globalPrepend. php files under the "/WEB-INF" directory under your framework installation directory:
GlobalPaths. php
------------------------------------------------
$ AppDirs [] = 'web-INF/lib/phpmvc_tags ';
GlobalPrepend. php
------------------------------------------------
Include_once 'phpmvc _ Tags. php ';
If they are not added to the path, define these variables.
Install the PHP. MVC Library
Download the latest PHP. MVC Library: http://www.phpmvc.net/download/cvsIdx.php? Doc = cvs-snaps
Decompress the library documentation to a directory. modify the path settings and Inclusion settings described above.
Run the example application
Download the sample application. The Complete Sample code file and this wizard can be downloaded here: http://www.phpmvc.net/download/rel/phpmvc-tags-v1.0.zip
Decompress the package to the web server directory. it may be like this: C:/WWW/PhpMVC-Tags.
Modify the application and framework settings.
To test the example program, you need to visit the home page of the example program: http: // localhost/PhpMVC-Tags/Index.html.
Appendix A: ViewResources configuration class
ViewResourcesConfig class Element configuration information.
The following table lists the attributes, description, and default values of the ViewResourcesConfig class:
Name |
Description |
Default Value |
$ AppTitle |
The application title |
'My Web application' |
$ AppVersion |
The application version |
'1. 0' |
$ Copyright |
The copyright notice |
'Copyright c yyyy My Name. All rights reserved .' |
$ ContactInfo |
The contact information |
|
$ ProcessTags |
Do we run the template engine processor (boolean) |
False |
$ CompileAll |
Force compile pages (boolean) |
False |
$ TagL |
The left tag identifier |
'<@' |
$ TagR |
The right tag identifier |
|
$ TplDir |
The view resource templates directory |
'./WEB-INF/tpl' |
$ TplDirC |
The compiled templates directory |
'./WEB-INF/tpl_C' |
$ ExtC |
The compiled file notation. Eg: "pageContent. ssp [C]" |
'C' |
$ MaxFileLength |
The maximum size of the template files allowed, in bytes (integer) |
250000 |
$ TagFlagStr |
Indicates tag template file (s) to be pre-processed. Eg: "myPage. ssp" |
'. SS' |
$ TagFlagCnt |
The number of trailing filename characters to sample (". ssp" =-4) |
-4 |