Re: templating

From: Date: Thu, 22 Jun 2006 23:26:17 +0000
Subject: Re: templating
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-238525@lists.php.net to get a copy of this message
On Thu, June 22, 2006 6:10 am, Ryan A wrote: > He just needs maybe 5 template > pages, same pages, different color. For something THIS simple, I truly believe you are Better Off (tm) with a simple head() and foot() function in a globals.inc file: function head($title = "My Site", $bgcolor = '#ffffff'){ ?> <!DOCTYPE ...> <html> <head> <title><?php echo $title?></title> </head> <body bgcolor="<?php echo $bgcolor?>"> <?php } function foot(){ ?> </body> </html> <?php } ?> Your header and footer are now in one "template-like" file which makes it easy to match up tags. And the 5 pages will look like: <?php require 'globals.inc'; head('Page One', '#fcfcfc'); ?> <p>Page One specific content here</p> <?php foot(); ?> The reason I prefer this to header/footer includes, is that it's too easy to mess up closing tags in footer/header out of sync with separate files, but with one file, they're right there and a decent HTML editor will pick them out for you. -- Like Music? http://l-i-e.com/artists.htm

« previous php.general (#238525) next »