Most web programmers are unfortunate when it comes to web design skills, and most web designers are unfortunate when it comes to programming skills. I consider myself a programmer, I can try and get creative with web design, but the result still looks amatuer and hasn’t got that wow feeling I try and aim for. I now prefer to write my scripts and then hire out a web designer to give my script that wow feeling.
Recently, I have had to write an online web quotation system for my fulltime job. I quickly decided that I will have to seperate the HTML code from the PHP code. This seperation will make the solution very flexible. I can hire out a web designer who can redesign my basic sample HTML templates to something that looks professional and they can even do this without access to the code, so I can protect my asset. By also seperating the HTML code from the PHP code, I can also create different theme skins for my system and even let the user decide which skin they prefer.
XTemplate is an example of a PHP template system. This PHP class allows you to seperate your HTML from your code. It is an open source project and has been around for a while. The class itself is well optimized and efficient and there are lots of large projects making use of it. Some of you may have heard of Smarty, which is another templating system. However, as far as I can tell this system still requires some code within the HTML and hence I prefer to use XTemplate instead.
The class itself is very simple to use. You can find examples in the XTemplate homepage. However, I believe the best way to learn to use it, is to take a look at other projects that make use of it. The Cube cart shopping script makes use of it, and this is how I discovered this templating class and now use it whenever I need to write any PHP scripts.
Templating systems have been around for a long time and if your writing your script in another language other than PHP, hunt the web for a templating system that will work in that language. By having your script’s processing seperate to its output generation, it will make creating spicy looking scripts a breeze.