How to create a template for the website

How to create a template for the website

If the website consisting of a set of pages is planned it is extremely important to know how to make a website template. It will simplify life both to the maker-up, and the programmer.

What is a template for the website?



Any website consists of a set of pages, at each of which there are identical elements: service information, menu, identical design design and so on. If to aim to change a similar element on all website - we will tell, to add new point to the menu, - that it is necessary to perform this operation on each page. If on their website 10, then a task not too difficult. And if 100 or more?


The template is the certain model implementing logic of display of material. In it it is possible to set the place of display of the menu, a cap of the website, the main content and so on. Contents of the elements registered in a template are set in a script or by means of the functionality provided by a management system of the website.

 

As a template it is possible to submit couple of documents. In one file there is a marking. It is the model where the specific location of any given content is specified. The second file is responsible for what will be displayed. The task of the second document is to analyze the file of the model and to substitute real values of variables.

These two documents are inseparable from each other as otherwise they are not so interesting: if to start the file of a template, it will not display any useful information. The same will occur if to start a script processor without the model.

How to create a website template?



Creation of a page layout of the website comes down to creation of simple HTML document in which the logic of display of elements of the page is registered. Along with it it is necessary to create the file managing display of a template. Real values of variables will be stated in this file.

Such work is rather labor-consuming therefore it is possible to use a ready shablonizator. It is possible to give as an example Smarty and Twig. In this case it is enough to download a shablonizator distribution kit, and according to the instruction to install it on the server. In this case it is not required to create the file which is responsible for display of real variables as it is already created - it is a distribution kit, that is file set. It is necessary to create only models of pages.

It must be kept in mind that modern shablonizator are rather multifunction. It is possible to speak about a separate programming language of templates as in models it is possible to enter display on a condition, in the scraper, etc.

Conclusion



Creation of a template - very good way to separate logic of display and logic of the application. It facilitates work to the maker-up and simplifies work of the programmer.

Author: «MirrorInfo» Dream Team


Print