Re: Standard template for output
| From: | php at minotaur dot nu | Date: | Sun, 16 Jul 2000 22:15:48 +0000 |
| Subject: | Re: Standard template for output | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-6851@lists.php.net to get a copy of this message | ||
On Thu, 13 Jul 2000 19:33:43 +0800, you wrote:
> is there a way to use a standard template for all my web pages, such
>that _any_ php script just have to include the file and output whatever is
>processed at a specific location in the template?
>
>i'm trying to design my app such that any design changes can be done in one
>file.
>
>Current Method (every php script must have a require at the top and bottom)
One method I came up with for a site was to have a file included for
each of several 'looks' of a page (eg, the front page, news pages,
community, links etc). This has been used very succesfully on one of
the larger sites I'm responsible for.
It's probably just easier to show you.
########################
<?php
## template './templates/front.php'
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head>
<title><?echo $PageTitle;?></title>
<link href="/style.css" rel="stylesheet" type="text/css">
<? echo $HeadTitle; ?>
</head>
<body>
<!-- pre-amble -->
<table><tr><td> ......
<?php
MainContent(); ## show in the unique content
?>
</td> </tr></table>
<!-- bla, blah, rest of page -->
</body>
</head>
################
<?php
## file: index.php, the front page
function MainContent();
{
?>
<!-- contents of main page -->
<?php
}
$PageTitle = 'Welcome to Ferrets Stuffers website!';
## we've defined the content in the function, now run a page that uses it..
include ($Config['templates'].'/front.php');
?>
################
Alister