Re: PHP and HTML - Templates Man

From: Date: Thu, 29 Jun 2000 06:52:06 +0000
Subject: Re: PHP and HTML - Templates Man
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-3740@lists.php.net to get a copy of this message
> Well if you want to change the markup/presentation of your page, all you > have to do is edit a seperate template file which contains all of your > markup, throw it into Dreamweaver for example, make your changes, then throw > it back on the server. No programmattic changes have to be made, so your > code/logic can remain intact. [...] > engines.. I really wish they would build one into php... Complete separation of the logic and display is a nice goal but it can be impractical aspects on most major applications. It's easy for just embedding variables (e.g. $Title) but most designs end up requiring more logic in the template system - e.g. loop over this dataset to build a menu, only show this item if they have permission $FOO, etc. This ends up requiring a miniature programming language to built into the template engine if you take the roll-your-own markup route. What I've compromised on is a treating templates as the final include file of an engine script. 98% of the logic is in include files and the template only contains sufficient PHP to format the data which has been provided by the library code. In one case I have an engine which basically includes necessary files, does a bunch of processing based on the URL parameters (including deciding which template should be used) and finally does an include($Template). The template is basically a PHP script which has a bunch of predefined functions and data, which almost eliminates the need for extensive processing in the template but does give the flexibility that advanced designs need. It's also useful that a relatively inexperienced PHP developer can build a template without needing to know how all of the library code works.

« previous php.general (#3740) next »