close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

nested dynamic menus

Thread began 6/01/2012 11:36 am by Christopher West | Last modified 6/05/2012 12:48 pm by Dave Buchholz | 1406 views | 13 replies |

Christopher WestCommunity Expert

nested dynamic menus

Hi I wanted to do a 2 nested dynamic menu for product categories. (Product Categories > SubCategory1 > SubCategory2).

Im using my existing database structure. currently I have a products table witch stores the ID of the main category and and ID of a subcategory (this was for a previous project).

Im trying to following the WebAssist tutorials - and Im wondering when the tutorial is refering to the "items" and "itemcategories" tables im assumning i can relate to my database as my database is "products" (this stores the ID for both categories and subsategories" and my second table "categories" but i did create a third table a while back called "subcategories" and this has a reference to the categories table.

all i require is my client to be able to have 2 subcategories from the main categories - now im just want to get an idea of the most logical table setup.

Chris

Sign in to reply to this post

Dave BuchholzBeta Tester

Is this the type of thing you are looking for http://www.i-cre8.co.uk/webassist/multiple-dynamic-dropdowns/ download the zip file to see how I structured the db tables

Sign in to reply to this post

Christopher WestCommunity Expert

Hi there thats a very helpful link and will use that in up coming projects..however for my current project its a little different...i have posted another thread as need help urgently on this matter: the basic idea is to have the following "dynamic" menu

(currently i am storing the IDs of category, subcategory1 & subcategory2 in my products table but this maybe totally wrong.) and I have the category, subcategory1 & subcategory2 tables that store the category name.

here is te menu layout:

Category
--> SubCategory1
-----> SubCategory2
-------->Product

any guidence would be awesome :)

Chris

Sign in to reply to this post

Dave BuchholzBeta Tester

Chris,

The logic behind the dynamic dropdowns is that each child dropdown is exactly that a child dropdown so they in db terms there is a foreign key that relates that child dropdown to it's parent.

So if I am understanding you correctly the 2 subcategories are stored in the same table ? If so are they only related back to the product and not to each other ?

Sign in to reply to this post

Christopher WestCommunity Expert

Hi Dave, yes currently the subcategories relate back to the product (because the Previous project needed a certain process in that way).

Ok I need more of a work flow, because I'm getting so confused. How would the database structure look for categories and products. And how would the admin go about adding...because I was thinking the only way is assign a product on one of the 'add category' pages rather then selecting a category from a drop down on the 'add product' page. At least adding a product during the 'create a category' page would make it easier to add. Product to multi categories (if needed) but to be honestly maybe this feature isn't really needed. But how can I assign a sub category on the product page?

Sign in to reply to this post

Jason ByrnesWebAssist

Before you get started used CSS Menu Writer for your own menu, i recommend getting familiar with creating a dynamic menu using the "Creating Dynamic Menus with CSS Menu Writer 2.0" tutorial on the Menu Writer support page:
css-menu-writer/

in the css menu writer download center page, there is a sample database in the "CSS Menu Writer: Solution Recipe Files".

for your categories:
for the categories table you should have an ID column, category name column and category parent column.

categoryID- Primary key
categoryName - varchar
categoryParent - int.

in the category parent column you store the ID of the parent category:

|------------+--------------+----------------|
| categoryID | categoryName | categoryParent |
|------------+--------------+----------------|
| 1 | Category | 0 |
|------------+--------------+----------------|
| 2 | Subcat 1 | 1 |
|------------+--------------+----------------|
| 3 | Subcat 2 | 2 |
|------------+--------------+----------------|




when you assign the product to a category, you would store the category ID in the products table.

Sign in to reply to this post

Christopher WestCommunity Expert

Thanks Jason, I did think to create the tables like that, but i think I started to lose logic...can I ask, how would the admin for the client be set up. because currently my admin that I have created for existing project consists of a page for creating categories and then a page for creating a product (this includes a select list of the categories that the client would select to assign that category to that product.)

If I use the same method above for this new category system...wouldnt the category select list become quite long once the client adds different sub categories etc..plus the client could possibly get confused to which subcategory belong to which category etc if they are all listed in the same select list.

this is why i did think about assigning the products to what ever category/sub categories on the same pages as creating those categories.

i guess both methods are ok, but which would be more efficient in terms of being better for the client. also if I assign categories/subcategories (in one select list) on the products page, how can I allow the client to add a product to many different categories (if they want to. would it be just a simple case of adding another select list and have another ID field in the products table?

so many ways of doing the same thing, but chosing the right direction at the beginning is what im struggling to decide upon.

So if you can give me your oppinion on the admin side of things that would be great :)

Chris

Sign in to reply to this post

Jason ByrnesWebAssist

I would create a link on the product update page for assigning the categories.


you would need to hand code the logic for the category select list to show the subcategories under the parent category, and indent it as well. you would need to use nested recordsets to display the subcategories. based on the parent category ID.

I sugest taking a look at Power Store, we implement this in the Power Store products update page.

Sign in to reply to this post

Dave BuchholzBeta Tester

FWIW I don't like the recursive nature of the method that Jason demonstrates :-)

That's not to say it is wrong I just prefer to have everything separated out into it's own table as per the example you have already downloaded from my archived site.

Sign in to reply to this post

Christopher WestCommunity Expert

Thanks Jason for the suggestions. Powerstore isn't an option as the website has already been built (I've used my previous Dinky Fingerprint website for the core code). Plus once I get this organise in my head it's just a case of implimenting it into my website.

I think (with the help of Dave's code on the select list from his website - thanks for the link Dave) I believe his technique would be spot on in being able to navigate the select lists :)

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...