[web] Website Design: Repeating Sidebars
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
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.
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.
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:
Tada :D
Edit: fixed source :S
[Edited by - Karan Bhangui on April 21, 2008 10:05:59 PM]
<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]
Quote:Original post by Karan BhanguiSo, basically, take all the sidebar code, then put it into a separate file, then call it from every other file?
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:
Quote:Original post by OluseyiI see that. Apparently I was misinformed. I'll rectify that situation when I get home. Thanks for catching that...Quote:(heck, Python is based on C++).Uh, no.
Ian
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:
Or like this:
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.
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.
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...
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...
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.
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.
It is more likely than not that you have PHP enabled on the server. Just upload a php file with something like:
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.)
<?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.)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement