Templates can improve the structure of your website. This article explains how to use a new feature of PHP 4 and the template class to skillfully use templates to control page layout in a website composed of a large number of static HTML pages.
Outline:
============================== =====
Separate functionality and layout
Avoid duplication of page elements
Template framework for static websites
== =================================
Separation function and layout
First let’s take a look at the two main purposes of applying templates:
Separate functionality (PHP) and layout ( HTML)
Avoid duplication of page elements
The first purpose is the most talked about purpose. It envisages a situation where a group of programmers write a A PHP script is used to generate the content of the page, while another team of designers designs the HTML and graphics to control the final appearance of the page. The basic idea of separating functionality and layout is to enable these two groups of people to write and use an independent set of files: programmers only need to care about files that only contain PHP code and do not need to care about the appearance of the page; while page designers can use their own Design your page layout with the most familiar visual editor, without worrying about breaking any PHP code embedded into the page.
If you have seen a few tutorials on PHP templates, then you should already understand how templates work. Consider a simple page part: the top of the page is the header, the left is the navigation bar, and the rest is the content area. This kind of website can have the following template files:
{HEADER} | |
{LEFTNAV} | {CONTENT} |