When you are building a site, you may have to face the following realities:
The site requires a programmer to design the program and a web designer to organize the page. So, is there a way to combine the two well?
Yes, the use of templates (fasttemplate: This program in the site's "program and Code" can be found), which will make your work easier.
Here's an explanation of the benefits of using templates:
1, in a very short period of time can replace the appearance of the entire site
2, so that programmers can abstract programming, without touching the HTML code
3, the speed is very fast
4, you can reuse the previous template
The origin of the template: Fasttemplate from the Perl package with the same name. It was ported to the PHP3 platform. All you need is a basic class file class.fasttemplate.php
To explain the difference between using a template and using the Echo or print commands to create an HTML page, echo and print are very useful when writing short scripts, but the organization and customization of the script is not good enough to be modified. Templates are much more efficient when writing a site that supports multinational languages, such as using echo and print to imagine the workload.
Do not worry, skilled use of fasttemplate will take up a part of your time, but these times will be in your future work to make up for, especially when the big project.
So, how do you use Fasttemplate?
The first step is to simply use the function
<@php
$tpl = new fasttemplate( "path");
@>
Where path points to the path where the template directory resides. This function creates a $tpl object that can then be assigned parameters, processed or used to create various pages, and so on.
Fasttemplate is based on the theory that a Web page is made up of a number of small parts. For example, Web pages are subdivided into title, page, foot, and so on. The entire page is given a variable name, each of which is given a variable name, and the smallest integral part is usually a string, and it is given a variable name. The specific processing time, is a layer of the inclusion relationship. The included section appears as a macro {name} in the previous layer. Finally, after a layer of upward output, to get the complete page.
So what is the lowest-level function to assign to a string:
<@php
$tpl->assign(name, "text");
@>
With this feature, Fasttemplate assigns the string text to the variable name, and the next level on the replaceable macro {name} content is text.
For example:
$tpl->assign (name, "Me");
This assigns the variable name to the string "me."