Page 1 of 1

Templat-izing the PHP Application

Posted: Tue Mar 03, 2009 6:03 pm
by leon_nerd
Hi Guys,

I have developed few PHP websites for a client. They all are nearly same except for the logo, colors and the site name. Now the client wants me to develop a prototyping system that will generate sites by just providing them the necessary basic info required to create the site viz - logo, site name, colors etc.

1.) I have understood that part. Now, this is what I was thinking of doing. All the pages will be generic in nature and they will be fed by a table that will contain the basic necessary info required like site name, colors etc. I can then retrieve this information on each php page and substitute the information wherever needed on my page. Now, I am not sure if this is really the best way to do this. Is it a good idea to run a MySql query and fetch the data each time the page loads? Is there some kind of template that I can make, some kind of array and then use it over the session?

I have seen some templates, like in Wordpress they have these {[info]} type code that substitutes the values on the pages. You just write something like:
<div id="username">{[user_name]}</div> and it works. Now, I am not sure what we call it actually but I would want to know more about it and also know that if this is a better way to do it.

Also, any other suggestion too is welcomed.

2.) The client also wants that whenever the protytpe is modified in future with feature additions etc then all the websites those have been created by it should get updated automatically. Now, I don't know if there is any "automated" way of doing this. Whatever pages I add or edit, I will have to manually transfer them to the FTP server + run the SQL queries resulting from the addition of new features. Am I right in thinking so? Or there is a better way to do this too?

Any and every help will be really appreciated.

Thanks.

Re: Templat-izing the PHP Application

Posted: Tue Mar 03, 2009 10:14 pm
by alex.barylski
Look into the use of Smarty or similar template engine.

When you gain experience using something like Smarty switch to a alternative syntax templates