page into another template anywhere. If you want to also make a template that contains variables for the page you want to insert, you'll find that the template class handles the job very well.
Create a new three file third.html,header.html,footer.html in the template directory. The content is divided into the followingThird.html
Here is a list
Header.html
Footer.html
As you can see, the examples in our previous sections are$TPL->set_file ("mai
many HTML codes. In the program, you only need to make sure that the variables are in the template, so that the template determines how to present these variables (or even not ).
Smarty basics
Install Smarty
First, we first determine the place where the program is placed.
In Windows, the location "d: appservwebdemo" may be similar 」.
In Linux, it may be like this: "/home/jaceju/public_html /」.
Download the latest Smarty kit: http://smarty.php.net from The Smarty official website.
After u
program is placed.
In Windows, it may be like this: "d: \ appserv \ web \ demo \」.
In Linux, it may be like this: "/home/jaceju/public_html /」.
Download the latest Smarty kit: http://smarty.php.net from the Smarty official website.
After unlocking Smarty 2.6.0, you will see many files, including a libs folder. In libs, there should be 3 class. php labels + 1 debug. tpl + 1 plugin folder + 1 core folder. Then copy the libs file to the main folder of y
program is placed.
In Windows, the location "d: appservwebdemo" may be similar 」.
In Linux, it may be like this: "/home/jaceju/public_html /」.
Download the latest Smarty kit: http://smarty.php.net from the Smarty official website.
After unlocking Smarty 2.6.0, you will see many files, including a libs folder. In libs, there should be 3 class. php labels + 1 debug. tpl + 1 plugin folder + 1 core folder. Then copy the libs file to the main folder of yo
variables are in the template, so that the template determines how to present these variables (or even not ). Smarty Basics Install smarty First, we first determine the place where the program is placed. In Windows, it may be like this: "D:/appserv/web/demo /」. In Linux, it may be like this: "/home/jaceju/public_html /」. Download the latest smarty kit: http://smarty.php.net from the smarty official website. After unlocking smarty 2.6.0, you will see many files, including a libs folder.
the principle of clearly separating the application logic from the webpage presentation logic. That is to say, PHP programs do not have too many HTML codes. In the program, you only need to make sure that the variables are in the template, so that the template determines how to present these variables (or even not ).
Smarty basics Install Smarty
First, we first determine the place where the program is placed.
In Windows, it may be like this: "d: \ appserv \ web \ demo \」.
In Lin
Smarty
First, we first determine the place where the program is placed.
In Windows, the location "d: appservwebdemo" may be similar 」.
In Linux, it may be like this: "/home/jaceju/public_html /」.
Download the latest Smarty kit: http://smarty.php.net from The Smarty official website.
After unlocking Smarty 2.6.0, you will see many files, including a libs folder. In libs, there should be 3 class. php labels + 1 debug. tpl + 1 plugin folder + 1 cor
the way I provide is suitable to bring the program to move over the program developers to use, so as not to worry about the host installed Smarty.
Folder settings for the program
With the author in Windows installation Appserv as an example, the program's Master folder is "d:appservwebdemo". After installing the smarty, we create the folder under the Master folder:
Under Linux, remember to change the permissions of Templates_c to 777. Windows will cancel it read-only.
The first small progra
Note the following points: 1. the position of the sample is based on the previously defined template_dir. 2. the variables of all included subsamples will also be interpreted .; 3. you can use "variable name = variable content" in "include" to specify the variables contained in the introduced sample, as in example 4 above.
Preface
Region content
Most of these blocks use if or for and while in PHP programs to control their display status. Although the sample version looks much simpler,
expanded freely
/Demo/cahce/# Place cached files
/Demo/configs/# place the configuration file that can be loaded
/Demo/templates/# place the template file
/Demo/templates_c/# place the files compiled for the template
You can change the name of the extracted Smarty-3.1.12 folder to the project name we want, and change the demo to the name of the folder where the encoding is stored.
2. debug Smarty-3.1.12
Create your own file and create index. php in the demo folder.
Create Template index.
only be used once in a script, and it is responsible for getting and displaying the template referenced by the Smarty engine
Prototype: var display (string template[,string cache_id][,string compile_id])
Parameter one: template is required and specifies the type and path of a legitimate template resource
Parameter two: cache_id specifies the name of a cache identifier
Parameter three: COMPILE_ID used when maintaining multiple caches on a page
Use the following method$smarty->display ('
template and using the echo or print command to create an html page. echo and print are very useful in writing short scripts, however, the organization and customization of the scripts made are not good, and it takes a lot of effort to modify them. templates are much more efficient in writing websites that support multiple languages, for example, echo and print can be used to imagine a huge workload. Don't worry. using FastTemplate will take part of your time, but these times will be compensate
Ideas:To achieve a balance between speed and ease of use (mainly refers to the convenience of the art design). The method of generating PHP files from HTML files (compile?) is used.Also want to balance between separating the display logic and separating the HTML codeFor example a Forum home page (index.php):
Code:
Require ('./template.php ');PHP files generated by HTML are prefixed with different styles.$tpl _prefix = ' defaul
-> assign ('question', '');$ Smarty-> assign ('answer', 'not very good ');
// Specify the value that contains 'name/number'$ Smarty-> assign (array ('question' => '', 'answer' =>' '); // This method is rarely used.Display () method
This method must be used in a Smarty-based script and can only be used once. it is used to obtain and display templates referenced by the Smarty engine.
Prototype: var display (string template [, string cache_id] [, string compile_id])
Parameter 1: template is require
Ideas:To achieve a balance between speed and ease of use (mainly refers to the convenience of the art design). The method of generating PHP files from HTML files (compile?) is used.Also want to balance between separating the display logic and separating the HTML codeFor example a Forum home page (index.php):
Code:
Require ('./template.php ');PHP files generated by HTML are prefixed with different styles.$tpl _prefix = ' defaul
takes a lot of effort to modify them. templates are much more efficient in writing websites that support multiple languages, for example, echo and print can be used to imagine a huge workload. Don't worry. Using FastTemplate will take part of your time, but these times will be compensated in your future work, especially in big projects. So, how to use FastTemplate? Step 1: Use the Function
Path points to the path of the template directory. This function creates a $
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.