Templates can improve the website structure. This article describes how to use a new function and template class of php4 to control page layout in a website composed of a large number of static HTML pages. Outline: separation of functions and layout prevents repeated page elements. static website template framework templates can improve the website structure. This article describes how to use a new function and template class of php 4 to skillfully control page layout in a website composed of a large number of static HTML pages.
Outline:
==========================================
Separation of functions and layout
Avoid repeated page elements
Static website template framework
==========================================
Separation of functions and layout
First, let's take a look at the two main purposes of the application template:
Separation of functions (PHP) and layout (HTML)
Avoid repeated page elements
The first purpose is to talk the most about it. it assumes that a group of programmers write PHP scripts used to generate page content, at the same time, another group of designers designed HTML and graphics to control the final appearance of the page. The basic idea of separation of functions and layout is to enable the two groups to write and use independent files: programmers only need to care about files that only contain PHP code, the page designer can design the page layout with the most familiar visual editor without worrying about damaging any PHP code embedded into the page.
If you have read several tutorials on PHP templates, you should have understood the working mechanism of the template. Consider a simple page: the top of the page is the page header, the left is the navigation bar, and the rest is the content area. Such websites can have the following template files:
Template example
{HEADER} |
{LEFTNAV} |
{CONTENT} |
Foo
Bar
We can see how the page is constructed by these templates: the main template controls the layout of the entire page; the header template and leftnav Template control the public elements of the page. The identifier in the braces "{}" is a content placeholder. The main advantage of using a template is that the interface designer can edit these files as needed, such as setting fonts, changing colors and graphics, or completely changing the page layout. The interface designer can use any common HTML editor or visualization tool to edit these pages, because these files only contain HTML code, without any PHP code.