This example describes the thinkphp template assignment and substitution method. Share to everyone for your reference. The implementation methods are as follows:
1. Assignment methods in the template:
Copy Code code as follows:
$this->assign (' name ', ' cloud-dwelling community '); The first method of assignment
$this->name= ' jb51 '; the second method of dynamic assignment
$this->display ();
2. Template Replacement Method:
PUBLIC__: will be replaced with the public directory of the current Web site, usually/thinkphp/public/, create a CSS folder and create a basic.css file
__ROOT__: Replace the address of the current Web site (excluding the domain name)/thinkphp
__APP__: Will replace the current project with the URL address (excluding domain name)/thinkphp/index.php;
__GROUP__: Will replace the current group of URL address (excluding domain name)/thinkphp/index.php/index;
__URL__: Will replace the current module's URL address (excluding domain name)/thinkphp/index.php/index/index;
__ACTION__: Will replace the current operation of the URL address (excluding domain name)/thinkphp/;
__SELF__: Replaces the current page URL
Replace the template variable rule, modify the configuration item
Copy Code code as follows:
' Tmpl_parse_string ' =>array (///Add your own template variable rules
' __css__ ' =>__root__. ' /public/css ',//Specify file storage directory
' __js__ ' =>__root__. ' /public/js ',
),
Call Method:
Copy Code code as follows:
href= ' __css__/basic.css ' href= ' __js__/basic.css '
I hope this article will be helpful to everyone's thinkphp framework program design.