Forum Moderators: coopster
I have a website...with main categories...and sub categories...
I have already separated the site into one index.php page that includes my header and includes my footer...
I have main category buttons at the very top...and a place for TEXT HYPERLINKS on the LEFT.
Now when I click a category button at the top, I want it to load the subcategory links for that category on the left...For example...When I click the About button on the TOP...I want the follow text links to open up on the left..."DJs, Light Tech's, Job Opportunities, Company Info".
Here's the challenge, I have static header right now (the header contains the information for the top and the left side bar! I made it like that so that if I change anything on the header, it will be applied through the entire site. Not just one category (in which I'd have to go through all the categories that have customised subcategorical links and change all of them).
So I guess I need to make this header dynamic, but how? Or perhaps separate the left side navigation? I'd appreciate ANY help!
I would suggest making your left nav dynamic.
You could maybe set a variable for the section you are in.
$section = "dj";
then for each of those variable you do a little test in the nav
if ($section == "dj") {
// dj links here
}
and then have that for each section.
make sense?
create a layout.html file
<html>
<head>
<title><!--Title--></title>
</head>
<body>
<table border="0" width="100%" cellspacing="1" cellpadding="1">
<tr valign="top">
<td width="150" height="350"><!--Navigation--></td>
<td height="350"><!--Content-></td>
</tr>
</table>
</body>
</html>
you should use comments, then you can manage the layout in something like dreamweaver. if you split up the layout into pieces ("header.php" "footer.php" etc etc ) then you end up with a real serious pain making changes.
my way also makes graphic designers like you a bunch.
then in index.php you read in the layout, inject the content and navigation, and anything else you want.
index.php:
<?php
$layout=@join('',@file('layout.html'));
$content = '<h3>this is the page</h3>
<p>Welcome to the page</p>
';
$title = 'fafafafoooolin';
$navigation = '
<div><a href="index.php?page=foo">foo</a></div>
<div><a href="index.php?page=boo">boo</a></div>
<div><a href="index.php?page=etc">etc</a></div>
';
$html = str_replace('<!--Content-->',$content,$layout);
$html = str_replace('<!--Navigation-->',$navigation,$html);
$html = str_replace('<!--Title-->',$title,$html);
echo $html;
?>
So if you use something like mod_rewrite, you build one index.php that is "the content engine", then your engine has intelligence to run php scripts that fill up $content, or you load in static html files into $content, and inject it into the template.
you can also get crafty and select alternate layouts for different content types, and adjust the content accordingly. one time, just for s&g, i had a site spitting out validated xhtml content to ie 6 browsers and validated html 4.0 content to all others. also, you can modify the content for wap, wml, etc.
so that's my suggestion ;-)
take care,
[edited by: waitman at 4:01 am (utc) on Aug. 15, 2003]
when i started building dynamic sites, i tried the head.php / foot.php, turned in to a nightmare when you had to make updates.
especially working with graphic design teams, and they want to try to update the look, etc of the site.
i have had good luck keeping content, code, and layout separate. content can go in a database or you can have flat html files (that do not contain any of the template ;-)
makes management a breeze.
take care,
-So are you saying to make the left SEPARATE from the top (in two separate includes)? Or does it not matter?
-Where would I put these variables to show which categorical section I'm in?
-How would I call upon the variable? (uh...make the text hyperlink...index.php?section=dj ?)
This is the test I currently have...
<?php
if ($section == "about") {
echo ("<a href="about/dj.php">About</a>");
echo ("<a href="about/lt.php">Light Techs</a>");
echo ("<a href="about/jobs.php">Job Opps</a>");
echo ("<a href="about/compinfo.php">Company Info</a>")
}
if ($section == "portfolio") {
echo ("<a href="porfolio/venues.php">Venues</a>";
//next link and so on
}
?>
And so on and so forth through the sections I already have...is this right?
Sorry I'm a newbie, but I'm trying to learn! :) Thanks you guys for your tremendous response so quickly!
it doesn't matter but I would put them in the same file.
Where would I put these variables to show which categorical section I'm in?
well in the top of each file you could have a $section = "sectionname"; before you include the menu. If you have the site seperated logically so each section is in its own directory you could have the menu itself figure out the directory it is in and serve up the appropriate menu.
is this right?
looks good to me