close ad
Help us test the new Databridge BETA with MySQLi support
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Menu Navigation Structure Logic

Thread began 10/14/2012 10:00 pm by Christopher West | Last modified 10/18/2012 2:43 pm by Php | 1272 views | 11 replies |

Christopher WestCommunity Expert

Menu Navigation Structure Logic

Hello ok, need some help in terms of logic structuring a menu system whereupon my client can create their own header menu items, these will then display sidebar sub menus which will be individual to the page that the header menu is linked to. furthermore there maybe a sidebar submenu that maybe shared with 2 or more header menu items.

im thinking this would require 3 tables

header menu
sidemenu
and linking menu

the header menu will also contain its own small icon image.

also the way i want to display the URL links is using the MenuName (rather then an ID value)

Plus I want the client to be able to control which menu items from the database will be displayed on the header menu (for example 6 months down the line they may want to make one of the sidemenus to be the header menu item)

And this will also involve them create new header menu items and even deleting menu items at will.

the menu name will also be stored in a "content" table in the database so that when the menu item is clicked then the relating content from the content table is dynamacially displayed.

Im just wondering if I am overcomplicating my logic with the 3 tables? Can it be done with less tables or does it require more tables?

I want to sort out my logic before coding.

currently my tables are as follows:

TopNav
#TopNavID
#TopNavName (this is the actual displayed name of the link + will shows in the URL)
#TopNavIcon (this stored a graphic image)
#TopNavState (this allows for the top menu items to be displayed or temporary disabled)
#TopNavLink

SubNav
#SubNavID
#SubNavName (this is the actual displayed name of the link + will shows in the URL)
#SubNavState (this allows for the sub menu items to be displayed or temporary disabled)
#SubNavLink

NavLink
#NavLinkID
#NavLinkParent
#NavLinkChild

If this is the correct approach then how can I join these tables together in the correct way to correctly display from my description?

regards

Chris

Sign in to reply to this post

Jason ByrnesWebAssist

your table structure looks correct, since you are trying to create a many to many relationship, you need to use a linking table.

you would need to use a join query to relate the two main tables based on the linking table.

assuming that NavLinkParent relates to TopNav.TopNavID and NavLinkChild relates to SubNav.SubNavID the structure of the query would be:

SELECT TopNav.*, SubNav.*
FROM TopNav
INNER JOIN NavLink ON TopNav.TopNavID = NavLink.NavLinkParent
INNER JOIN SubNav ON SubNav.SubNavID = NavLink.NavLinkChild

Sign in to reply to this post

Christopher WestCommunity Expert

Well I am gladd I am on the right path...obviously though when I query the URL I want to be refering to the actual names of the menu items in the URL rather then the ID there for I can use URL queries such as ...co.uk/mywebpage.php?Content=About Us .....rather then ...co.uk/mywebpage.php?Content=28 So shouldnt I be joining using the actual field name in the database table?

Sign in to reply to this post

Jason ByrnesWebAssist

no, you join on the ID's.

you use the a where clause to return the relevant records.

Sign in to reply to this post

Christopher WestCommunity Expert

ok cool as long as I can use the actual names of the menu items in the URL then I am happy as ideally I want to use.htaccess rules to modify the URL to make them look user friendly for links :)

....I was thinking though if I were to join using the ID (what if) the client later deletes a menu link (the reference via the ID would be broken) then later they decide to recreate the same menu link "name" but then the ID reference...I guess then if they were to delete that menu link I would need to make sure I code it so that the link table would also be deleted. does that make sense?

Sign in to reply to this post

Jason ByrnesWebAssist

YEs, that is all correct.

Sign in to reply to this post

Christopher WestCommunity Expert

ok, so to confirm even though I showed concern about the future deletion of menu links I still NEED to link via the table ID AND need to delete the referencing linking table as well at the same time if I want the client to be able to re-create the same menu link name at a future time? :)

Sign in to reply to this post

Jason ByrnesWebAssist

yes, that is correct.

Sign in to reply to this post

Christopher WestCommunity Expert

ok finally would I still use the same database table structure if in the future I wanted to make one of the sidenav menu items to become one of the topnav menu items? The one way I can see this happening is physically copy the record in the sidenav to a new record in the topnav table....But I am sure thats a clumsy way of doing this process...unless if I have used the recordset you suggested all then the topnav and sidenav would work as one and then all I would do is for the top name display ALL record with a certain field value set to 1 and for the sidenav display all records with a field value set to 2 (for example). Would that be a better approach? Therefore in both tables I should create a field called "TopNavState" and in the sidenav create a field called "SideNavState" ..or am I not getting my logic messed up?

Chris

Sign in to reply to this post

Php

What are trying to create?

Hi I'm stumbled on to this post what are you trying or created I'm curious?

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...