I’ve gotten advice on here before on my site, and I greatly appreciate it, but I’m at another stopping point.
I’m redoing a large, fairly dynamic website. There are 4 main categories, that the site is divided up into. The displayed pages are generated by the URL string which is similar to:
[url]http://www.mysite.com/subnav/page.php
The .htaccess redirects everything back to the index page. From the index, it pulls the subnav to display, builds the page with the correct styles, (different styles for each category), then includes the actual page (in this case, page.php). This seems to work really well so far, but I’m starting to run into a problem now.
On some pages, I want to include a special css file for only that page. This is a problem, because the page.php file is basically just included in the body part of the html.
I was thinking about doing an fopen on the page.php file. Then, if I set some variables for that page, they would be useable when the page is built.
Does this seem like a smart way to do this? Am I doing this completely backwards? Any advice would be appreciated. I’ll attach my index file as of now, which I think will explain what I’m talking about a little more.
Thanks, and any advice is greatly appreciated.
[code=php]<?php
$request = $_SERVER[‘REDIRECT_URL’];
$request = explode(‘/’, $request);
//Sets footer and main navbar for site.
$header = ‘template/header.php’;
$navbar = ‘template/navbar.php’;
//Check to see if there is a subnav, then get correct template file and set page to display.
if (!isset($request[2])) {
$template = ‘one_column_layout.php’;
$type = ‘one_column’;
$page = ‘pages/welcome.php’;
}else{
$template = ‘two_column_layout.php’;
$type = $request[1];
$subnav = ‘template/subnav/’ . $request[1] . ‘.php’;
$page = ‘pages/’. $request[2];
}
?>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en” >
<head>
<meta http-equiv=”content-type” content=”text/html; charset=iso-8859-1″ />
<meta name=”author” content=”Jesse A. Inskeep” />
<meta name=”keywords” content=”Quad Cities, tourism, Quad City, visit, Davenport, Bettendorf, Moline, Rock Island” />
<meta name=”description” content=”Quad Cities Convention and Visitors Bureau Home Page.” />
<meta name=”robots” content=”all” />
<title>Quad Cities Convention & Visitors Bureau</title>
<link rel=”stylesheet” type=”text/css” href=”/styles/styles.php?type=<?php echo $type; ?>” />
<script src=”/include/swfobject.js” type=”text/javascript”></script>
</head>
<body>
<div id=”main”>
<?php
include ‘template/header.php’;
if ($template == ‘one_column_layout.php’){
include ‘template/flash_header.php’;
}else{
include ‘template/picture_header.php’;
}
include ‘template/navbar.php’;
include ‘template/’ . $template;
include ‘template/footer.php’;
?>
</div>
</body>
</html>