Re: templating

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux