# [web] Website Design: Repeating Sidebars

## Recommended Posts

Geometrian    1810
Hi, -This is my website: http://www.geometrian.com/Programs.html -As you can see, there is a title and a top and side bar. -Note that Projects.html and Message%20Board.html have precisely the same setup, and every one of my projects is accessible from any page. -Every time I release a new project or a new update, I must update these three pages' sidebars. I must change the links to the file on the sidebar. This is annoying. -As if this weren't bad enough, I want to add more pages, but I'm not willing to update five or six pages every time I change one thing. -I've heard of a way to change one file and have it change many pages that are based on it. I've heard that this is faster, too, as it must only load the sidebar once. This is precisely what I need. -Could someone please show me what to do with this website, or create a simple example site that shows how to deal with this problem? Thanks, Geometrian

#### Share this post

##### Share on other sites
swiftcoder    18437
If you are developing this site in straight HTML, Dreamweaver (among others) allows you to define the navigation bar as a 'library item', and include it in each page. If your server supports Server Side Includes, you can use those to add the menu bar. You can also achieve the same result using php/asp/jsp.

However, I would very much suggest that you transition to a Content Management System (CMS) instead. Modx is quite nice, although for a site this small you might consider abusing WordPress instead.

#### Share this post

##### Share on other sites
You don't need a CMS at all. Change all your main files into .php extensions. Then, take everything in your <div class="nav"> and put it in a file called sidebar.html. Now go back to your php files and add this instead of the entire sidebar:

<div class="nav">  <?php include_once(sidebar.html); ?></div>

Tada :D

Edit: fixed source :S

[Edited by - Karan Bhangui on April 21, 2008 10:05:59 PM]

#### Share this post

##### Share on other sites
Oluseyi    2112
Quote:
 (heck, Python is based on C++).

Uh, no.

#### Share this post

##### Share on other sites
Geometrian    1810
Quote:
 Original post by Karan BhanguiYou don't need a CMS at all. Change all your main files into .php extensions. Then, take everything in your
So, basically, take all the sidebar code, then put it into a separate file, then call it from every other file?
Quote:
Original post by Oluseyi
Quote:
 (heck, Python is based on C++).
Uh, no.
I see that. Apparently I was misinformed. I'll rectify that situation when I get home. Thanks for catching that...

Ian

#### Share this post

##### Share on other sites
Maxamor    361
Yes, essentially you want to isolate what is static from what is dynamic. Put your navigation into its own file and include it on every page using any of the aforementioned mechanisms.

To do it with SSI (Server-side includes) you can do something like this:

<!--#include virtual="/path/relative/to/the/web-server/root/navigation.html" -->

Or like this:

<!--#include file="path/relative/to/the/file/navigation.html" -->

Info about file and virtual.

As a good practice you should use a .shtml extension if your file has SSI processing instructions. Most of the time, though, servers are set up to parse files with .html and .htm extensions too. There's a small performance hit for doing it this way (since .html and .htm files will be parsed for SSI instructions whether they have any or not) but I wouldn't worry about it.

#### Share this post

##### Share on other sites
Geometrian    1810
Neither of these worked.

In the case of the former, I think it is because my server doesn't use php. How can I install it?

In the case of the latter, Dreamweaver CS3 (what I use) seemed to recognise it, but opening the file in Firefox didn't get the right effect. It said "Server Side"--does that mean it has to be FTP-ed first?
Edit: FTP-ing my test site didn't seem to help...

#### Share this post

##### Share on other sites
Maxamor    361
You're correct in your first assumption -- including files with SSI is indeed processed by the server. Opening them locally will not do the trick (DW will emulate this effect, though).

One way to tell if your server has SSI turned on is to view the source after you've FTP'd it to the server. If the include processing instructions are still there then the server is not processing them.

The effects with PHP will be the same.

#### Share this post

##### Share on other sites
Geometrian    1810
How do I activate SSI or PHP then?

#### Share this post

##### Share on other sites
It is more likely than not that you have PHP enabled on the server. Just upload a php file with something like:
<?php echo 'test'; ?>
to test if you do. If it prints test, then its installed. No further 'activation' is required.

And I highly suggest the php option, the rest are a bit nonstandard/outdated.

(Edit: Fixed php source in previous post. I forgot to add the <?php and ?> tags which tell apache to activate php parsing, which is probably why it didn't work.)

#### Share this post

##### Share on other sites
Geometrian    1810
It does print test. But the website is still not working...
Edit: It is working, but not in the right way: http://geometrian.com/TestSite/Programs.php

#### Share this post

##### Share on other sites
Geometrian    1810
Opps. Wait nevermind. The titlebar and sidebar had to be split into separate files. It works now! Thank you very much everyone!
G

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account

## Sign in

Already have an account? Sign in here.

Sign In Now