Re: Real world usage of IT [template] class?

From: Date: Mon, 08 Apr 2002 16:26:32 +0000
Subject: Re: Real world usage of IT [template] class?
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-1106@lists.php.net to get a copy of this message
le 8/04/02 17:46, derek fong à pear@subtitled.com a écrit : > Hi, > > I'm basically just trying to brainstorm ideas on how to properly structure > the code for templates at a low level. I think the page you pointed me at > is a good basis. But for me, my concerns are more along the lines of what > actually goes into the PHP script that calls the template logic? It seems > to me that if all template parsing is done by a centralized function (since > reproducing it in every single PHP script seems redundant since it's all > doing the same thing anyway, i.e., load the template file, parse it, display > it), it's theoretically possible that nothing needs to be put into the PHP > script itself except for the actual static content of the page. And this > also poses some conceptual problems for me. If I have a global, site-wide > template file structured like this: > > <html> > <body> > {CONTENT} > </body> > </html> > > Then doesn't that mean that in order to change the content portion (which > would be straight HTML), a designer would have to go into the actual PHP > script? Doesn't that negate a major advantage of using templates in the > first place, in that designers should never need to see a line of PHP code? > Or does that mean that {CONTENT} should be replaced by a file block which > contains the HTML content for the page, and that that file should be placed > in a separate repository for designers to manipulate? So you'd basically > have a directory structure like so: > > /templates > site.tmpl.php (contains global navigation and look-and-feel for whole > site) > /includes > parse_template.inc.php (functions parse the site template for each page > in public_html) > /content > index.tmpl.php (contains static HTML page content) > page1.tmpl.php > /public_html > index.php ("dummy" scripts since they don't really do anything) > page1.php > > My apologies if what I'm asking isn't clear, but I'm still trying to get my > head around some of these concepts and how to make them work in the best > possible way to separate the code from design, while at the same time making > sure that it's not too "heavy" and easy to extend the system later if > necessary. > > -f Derek, If all you want is display HTML static content, just use HTML files as they are much faster to parse. Otherwise, your directory structure looks fine to me. Maybe I would just put template and contents in the same directory. The other alternative in the case your content doesn't change much is to use Smarty which create pre-parsed (cached) templates, thus avoiding to reparse the php code all over again (http://www.phpinsider.com) which represents gain in time. bertrand

« previous php.pear.general (#1106) next »