How to: dynamic sub-menu's? (Full Version)

All Forums >> [Web Development] >> General Web Development



Message


pcguy -> How to: dynamic sub-menu's? (4/29/2009 15:13:01)

Hi Folks,

I'm redesigning an ASP site with Dreamweaver CS4, so I'll be sticking to using ASP technology....

The site will use horizontal navigation for the MAIN MENU which will be static, but each page therein will have a vertical sub menu, probably with 2-3 levels deep - which will need to be dynamic.

I'm trying to figure out a good way to organize and maintain the submenus. I need each page to "know where it is" so the breadcrumb trail can be accurate and dynamic. The page/menu will also need to know how to display the correct submenu/level.....hopefully this all can be dynamic....

I also want to avoid query string parameters, such as page.asp?menu=1&submenu=3 type stuff.....

My current thought is to use URL rewriting and a database - but I'm not sure if this is the best route....

Does anyone have any suggestions? HELP!

Thanks!




TexasWebDevelopers -> RE: How to: dynamic sub-menu's? (4/29/2009 16:15:47)

Here is our bit on breadcrumbs:
http://www.texaswebdevelopers.com/blog/template_permalink.asp?id=105
You can get the page you are on by using server variables:
http://www.texaswebdevelopers.com/examples/servervariables.asp
So you can include a menu depending on where the user is:
<% If Request.ServerVariables("HTTP_REFERER") =http://www.yoursite.com/directory/page.asp Then %>
<!--#include file="menu1.asp" -->
<% else %>
<!--#include file="menu2.asp" -->
<% end if %>
All the menu URL's should be Full (long) URL's instead of relative to the page.
This can get kind of kludgy....




pcguy -> RE: How to: dynamic sub-menu's? (4/30/2009 5:38:12)

Yeah, I can see that getting kind of ugly....especially if you did it for the whole site...

However, it might ok to have a separate include file for each folder below the root - I'll have to play with that...

Thanks for the info...




clum1 -> RE: How to: dynamic sub-menu's? (5/4/2009 9:29:06)

I've just done something similar with my intranet's menu system; I've used Request.ServerVariables("SERVER_NAME") to create a "root" address for each link and it's cut down a lot of the kludge:

CurrServerName	=	Request.ServerVariables("SERVER_NAME")
RootAddress		=	"http://"&CurrServerName&"/intranet/"


So, for instance, a hyperlink becomes:

<a href="""&RootAddress&"contacts/"" title=""Staff Details"">Contacts</a>


so each actual address is just it's relative path and I can use the same menu for my dev server and production one...

It's been a real boon - previously I had my menu system using FP include files which took an age to update; now one ASP page handles the lot. I played around with the idea of using a database but it didn't really offer me anything. In the end I plugged it into a heavily adapted version of this JS dropdown menu.




TexasWebDevelopers -> RE: How to: dynamic sub-menu's? (5/4/2009 11:45:12)

Great idea---but I think it has the same issues when there are multiple sub-webs because you have to specify the name of the subweb directory (your root address) for each sub-web. That by itself might be hard to keep up with. And, I got the impression from the post that "2-3 levels deep" meant sub-webs and sub-sub-webs, etc. rather than different directories in the root which complicates things even more.




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.078125