| Languages Used |
|---|
| XHTML PHP CSS |
2. Now you have all the framework from the CSS, or whatever you used for the site. Now you have to decide what elements of the page you will want on every page of the site. In my case I have everything except the main center column, or the main body, in the master page.
3. Start coding the master.php.
CODE BLOCK 1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
5. Next is to link to any external files, set up meta data, and add a title to the page. This is where your first line of PHP will come in to play.
CODE BLOCK 2
<head>
<meta name="revisit-after" content="30 days" />
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII" />
<title>Your Domain - <?php echo $pagetitle; ?> </title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
7. You see your first line of PHP code here in the line that starts with title. The ?php tells the server to run this as PHP, echo tells the server to write the contents of the following variable, $pagetitle to the browser window. We must remember the variable name for later, it is how we will link to the actual content.
8. Next we create the framework for the page. I am also using CSS, so there are many div tags here separating my page contents.
CODE BLOCK 3
<body>
<div id="pagewidth" >
<div id="headerleft" >
<!-- Place Holder for the header -->
</div><!-- headerleft end div -->
<div id="wrapper" class="clearfix" >
<div id="twocols" class="clearfix">
<!-- Start the main content -->
10. The div tags all read from the CSS file for formatting the page.
11. The next line of code in Code Block 4 is our next line of PHP.
CODE BLOCK 4
<?php echo $pagemaincontent; ?>
CODE BLOCK 5
</div><!-- twocols end div -->
<div id="leftcol" >
<!-- Place holder for a navigation menu -->
</div><!-- leftcol end div -->
</div><!-- wrapper end div -->
<div id="footer" >
<!-- Place holder for a footer -->
</div><!-- footer end div -->
</div><!-- pagewidth end div -->
</body>
</html>
14. In this particular case we have design the whole page, minus the main content, and it will be reused from page to page. If we ever have to change links, or give a new logo in the header, all we make is one change and all of our pages are updated instantly.
15. Now to see how the content pages are created, click here.
