I'm making a website where each page has the same design, obviously its
a bad idea to put the same code/html in each page so what is the best
way to do this?
What I'm doing at the moment is putting a file called 'index.php' and a
file called 'content.php' in each directory. 'index.php' would set a
variable called $content with the full path for 'content.php' then it
would have an include() statement which called a script outside
public_html called 'template.php'. 'template.php' would be the basic
template for every page and where the content is it would have the line
'include($conte nt);'. Here's what my scripts basically look like:
--
/www/mysite/public_html/subpage/index.php:
<?php
$content = "/www/mysite/public_html/subpage/content.php":
include("/www/mysite/private_html/template.php");
?>
--
/www/mysite/public_html/subpage/content.php:
<h2>Content goes here</h2>
--
/www/mysite/private_html/template.php
<title>mysite </title>
<h1>welcome to my site</h1>
<?php include($conten t); ?>
--
This all works as it should, but I'm just wondering is there a better
way to go about this? I've found that it creates a lot of work when I
move or rename directories and also when I move the scripts between
servers as the full path will change and every index.php will need to
be updated. Sites like eBay and Amazon have the same design for each
page, how are they likely to be doing it?