Hi all, i need some advice on how to structure my taxonomy/category information.

Basically I want to do something quite simple and common I think. I want the user to select an item, then depending on that item there are further option sets, and I want the user to select one item from each set.

Now specifically my case:

I have a custom module called Order which works fine, and I want the user to be able to select what kind of medium it is on, and some medium specific options, some of which affect price, some of which dont.

I am using the categories module because I need different info assigned to different stages of the taxonomy.

The first basic tree I came up with is:

Mediums (container)
--- Canvas
      --- Stretched
      --- Unstretched
--- MDFBlock
      --- 12mm
      --- 18mm

Canvas, MDFBlock are Medium Category type flexinodes. On a seperate page I list these with a blurb on each, and a few images per Category.
Stretched, Unstreched, 12mm, 18mm are Medium type flexinodes - these have no images assigned but have a price/cm^2. Orders placed must be one of these - on order_validate i check the $node->type against Medium to make sure Medium is picked and not a Medium Category (i.e. Canvas, MDFBlock etc.) and calculate a price based on dimensions entered etc.

So far this works perfectly, but the complication comes here. I also want to add medium options, which depend on the selected Medium Category, not the medium itself. E.g. For canvas there are 2 options wrapping (wrapped or not), wood thickness (1", 1.5"). For MDFBlock the edges can be painted black, white or left natural.

So I have been going crazy trying to figure out how to do this all!

Two ideas come to mind, both arent very nice and involve duplicating data which I hate.

One is creating a brand new tree of categories called Medium Options:

Medium Options (container)
--- Canvas Options
     --- Wood Thickness
          --- 1 3/4 inch
          --- 1 inch
     --- Wrapping
           --- gallery wrapped
           --- no wrapping
--- MDF Block Options
     --- Side Paint
           --- matte black
           --- natural MDF
           --- white emulsion

So there are 2 dropdowns for the user. The user selects a medium from the first tree, then an option from this tree.
The downsides of this are:
- Medium Categories are duplicated
- The user can select an option for a different medium category than the one he selected!! (I had a look at activeforms module but couldnt figure out how to use it in this case!)

The other solution is duplicating the options and placing them directly into the mediums tree, so there is only one tree and one dropdown for the user:

Mediums (container)
--- Canvas
      --- Stretched
            --- Wood Thickness
                  --- 1 3/4 inch
                  --- 1 inch
            --- Wrapping
                 --- gallery wrapped
                 --- no wrapping
      --- Unstretched
            --- Wood Thickness
                  --- 1 3/4 inch
                  --- 1 inch
            --- Wrapping
                 --- gallery wrapped
                 --- no wrapping
--- MDFBlock
      --- 12mm
           --- Side Paint
                 --- matte black
                 --- natural MDF
                 --- white emulsion
      --- 18mm
           --- Side Paint
                 --- matte black
                 --- natural MDF
                 --- white emulsion

This is a nastier solution I think, much more data is duplicated, and the resulting dropdown is too ugly and doesnt make sense.

Ideally I want 2 dropdowns, but the 2nd dropdown shoudl update dynamically to only show the options based on the category chosen in the first step - and obviously the category information shouldnt be duplicated.

This seems like something which would be needed quite a lot but i cannot figure out how to do it!! any ideas?!

Comments

stanbroughl’s picture

i'm in taxonomic hell as well so i'm bookmarking this to see what suggestions you get

high1memo’s picture

I think with just taxonomy it just isnt possible at all. To be honest I can't believe how anybody could get anything done without the category module! It seems so natural to me that taxonomy should be node objects, and vice versa so you can assign properties to them (it seems maybe the CCK has similar functionality, but isnt ready yet or something).

The only other solution i can think of for my problem, is going outside of traditional taxonomy.

I setup a very simple tree of taxonomy with just the Medium Category:

Mediums (container)
--- Canvas
--- MDFBlock

Then I create 2 types of Medium data:, a Medium Instance (Stretched, Unstreched, 12mm, 18mm etc. i.e. the options that affect price) and Medium Option (gallery wrapped or not, white emulsion etc.).

So far thats the same as what I do.

But then I dont convert these nodes into taxonomy at all, I just tag them with the appropiate taxonomy (Canvas, or MDF Block etc.)

Thats all very fine and dandy, the question is, how do I tag an Order with one of these! Every Order needs to be assigned exactly one of each Medium data type, one Medium Instance, and one of each Medium Option type (there may be more than one medium option for a category, e.g. wood thickness AND wrapping for canvas)

OUCH my head hurts... this seems like such a 'needed' thing, I can think of a billion situations where one would be faced with a situation like this, I can't beleive there isnt an existing solution for it...

(actually my application is quite more complex, there are also graphics styles to choose from, which have sub-styles, some of them are affected by the number of people in the photo, some not etc... but that all works now, you can see my order form at http://www.cust-art.com/orderform if interested, click preview to see a summary of the order, no need to submit).

sepeck’s picture

Not sure if you have tried Views module. Looking at your site it may not work for you, but it is a query builder
This site http://www.activefarming.com/classifieds/animal-directory is using Views module to accomplish that page.

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide -|- Black Mountain

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide

high1memo’s picture

yea im quite familiar with the views module. It is only for quering and displaying data though, and my problem is more than displaying, its mainly internal organizing of the data - and then dynamic dropdowns to respond to

that site you showed is a perfect example of a similar problem - they have come across the same dilemma, and decided not to solve it. So the user can search for Alpine fish in florida! Or nigerian dwarf ducks in australia! I dont want to let my users do that. I'm sure nigerian dwarf is a type of breed of some kind of animal, but probably not ducks. I dont know what it is a breed of, but lets say it is a breed of horse, so that breed option should only be available if the animal you select is horse. BUT if the country you select doesnt have that breed of horse it still should not be available.

My case is even more complicated because I want the TITLE and number of dropdowns to change as well! (e.g. if you select horse, it should ask what breed, what color and whether its tame or not; if you select fish it should ask salt water or sea water, tropical or not etc.)

I know the activeform module can take care of detecting when a selection is made in a dropdown - but the big problem is how do you organize such data!

P.S. I felt I worded this questions quite badly and confusingly, and a bit off the point actually, so I posted a similar question here http://drupal.org/node/74747. Much more to the point though i think (hopefully!)