Dynamic Sidebars

Cyberbrak

Beta member
Messages
2
Hey all,
I've yet to find a good explanation of how to achive selected dynamic elements in a website. What I'm looking to do is keep the left (navigation) and right (features, updated daily) nav bars the same on all the pages of my site without changing the code on every page. So, pretty much dynamic objects, as I've been told. But... how does one do this?

I've seen some bad explantions of this in the past, but nothing concrete. If someone could explain an effective way to achive this, I'd be one happy monkey. :)

Thanks!
Cyber
 
the easiest way to do this is to just use a dynamic language, (for this example I'll use PHP) and have a wel organised folder structure, again I'll make some suggestions...

First the folder structure, I suggest that you have a root folder (obviously) and in this page you put a file called index.php and a file called menu.html and sidebar.html
inside of the root folder you have a folder caled pages, inside of this folder you put all your content pages. eg, home.html, links.html, gallery.html

now here is the part that achieves what you want to do...

Make the index.php page like this.
(you might want to change the layout etc...)
Code:
<?php
$page = $_GET['page'];
if ($page=="")
{
$page="home";
}
//first start the html layout of the page.
print"
<table width=100%>
  <tr>
    <td colspan=2>";
include('menu.html');
print "</td>
  </tr>
  <tr>
    <td width=20%>"
include('sidebar.html');
print "</td>
        <td>";
include("$page.html");
print "</td>
  </tr>
</table>";

?>

now you see that when you browse to the site you automaticall see the page home.html, you make your menu links in the follwing way...
Code:
<a href="?page=gallery">View Gallery</a>
<a href="?page=links">Links</a>

Hope that was helpfull, if you don't understand anything or need an example in a differnt languae (web language -I only seak english!) then just ask!
 
Awesome! Thanks for the info. I'm going to give this a shot later tonight, but it looks like that's exactly what I needed.

Cyber
 
Back
Top Bottom