[web] Navigation bar

Started by
6 comments, last by Sander 18 years, 10 months ago
I'm changing a website from having a navigation bar as a separate frame, to using CSS to position the bar at the side of the screen. But this raises a couple of problems: 1)If the bar is now part of the page, I don't really want to cut 'n' paste the code for it into every page - this just seems pointless and not good if I want to change anything later. 2)I want the navigation bar to know which page you're currently on. For isntance if you click on the 'downloads' item on the bar, the page loads and the 'downloads' item in the bar is now not a link. So what is the easiest way to accomplish these things? I can easily put a variable in each page (or use the pages' filenames) to tell which page is currently loaded; to save having the same nav-bar code in many places I could put it all in a java function in a separate .js file? Or I could use ASP/PHP but is that required here?
Advertisement
There are several ways to achieve this, but I always do this using PHP.

1) You can then just use <? include("menu.php"); ?> and then there should be your one menu page.
2) If you use a variable like page. This gives you the option to for example use this also in your menu to highlight the active item etc.

I think there are enough resources on PHP on the web to find out how to do this exactly.
Maybe I should refresh my server-scripting skills! I've done this or something similar in ASP but it was so long ago... I did implement a java version but that was dependent on java being turned on for the browser. I'd better find out what scripting the server supports - is it common for PHP and ASP to be supported on a server or is it normally one or the other? (This is for a client not my own site)
PHP is (and can be) installed on almost any server, ASP only on servers running Microsoft Windows Server.

Noteworthy: recently, there has been an invitation made for hackers to hack 'www.hackiis6.com', because it would prove how secure the new Windows Server version was. Well, if you visit it right now (01-06-05), it's (finally) offline! So IIS is pretty insecure.
Something like this? You might want to check out Smarty.
Rob Loach [Website] [Projects] [Contact]
Quote:2)I want the navigation bar to know which page you're currently on. For isntance if you click on the 'downloads' item on the bar, the page loads and the 'downloads' item in the bar is now not a link.
If you can live without this feature (a lot of sites do), a sitewide navigation bar could be accomplished with a simple server-side include. Otherwise, you would have to do server-side scripting, either by using the 'variable' method or some fancy string matching stuff.
Free Mac Mini (I know, I'm a tool)
Quote:Original post by Pipo DeClown
PHP is (and can be) installed on almost any server, ASP only on servers running Microsoft Windows Server.


Unless of course you decide you want to run ASP on another platform without regard for FUD, in which case you simply use a LINUX/UNIX/Mac/BSD/Solaris ASP platform (like Chilisoft).

Quote:Original post by Rob Loach
Something like this? You might want to check out Smarty.


Smarty is probabely a tad overkill for just a menu include, but for more complex sites it's definately a great tool!

<hr />
Sander Marechal<small>[Lone Wolves][Hearts for GNOME][E-mail][Forum FAQ]</small>

This topic is closed to new replies.

Advertisement