Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to have a menu like this in surfdome. I don't mean the UI but the flexibility of this menu.

I will try to explain it.

I have some products. I want to match these products with some categories and have multiple type of menus based on these categories.

e.g. (in [] are the categories and in () are the products)

A menu like

[Men] -> [Shoes] -> [Running] -> (Product1)
[Men] -> [Accessories] -> [Running] -> (Product2)
[Women] -> [Shoes] -> [Running] -> (Product3)
[Women] -> [Accessories] -> [Running] -> (Product4)


[Running] -> [Men] ->[Shoes] -> (Product1)
[Running] -> [Women] -> [Shoes] -> (Product3)
[Running] -> [Men] -> [Accessories] -> (Product2)
[Running] -> [Women] -> [Accessories] -> (Product4)


[Shoes] -> [Men] ->[Running] -> (Product1)
[Shoes] -> [Women] -> [Running] -> (Product3)
[Accessories] -> [Men] -> [Running] -> (Product2)
[Accessories] -> [Women] -> [Running] -> (Product4)


What i think it could be done with a tag system, but i would like to ask if anyone know a way to do it?

share|improve this question

yes, tagging and permuting the tags will do the the job.
you should ask yourself, if you need all the combinations, like for the single triplet Men-Shoes-Running:

[Men] -> [Shoes] -> [Running]
[Men] -> [Running] -> [Shoes]
[Shoes] -> [Men] -> [Running]
[Shoes] -> [Running] -> [Men]
[Running] -> [Men] -> [Shoes]
[Running] -> [Shoes] -> [Men]

but beware that if you need 4 tags to describe a product, the number of combinations is probably already prohibitive for a useful user-interface (factorial 4!: 24 combinations for that product category).

to reduce this, you might define flags like top_level_category.

the other option is to use multiple trees, which will give you a more direct control but will be more difficult to maintain (especially if you have frequent changes in products and categories)

share|improve this answer
Why do you think that the number of permutations matters? It's not like you need to display every permutation at the same time. – CodesInChaos Feb 28 '13 at 11:26
@CodesInChaos, I think the OP wants to create the menus for a range of products fully dynamically from a set of product-taggings (see e.g. the page he has linked). on the other hand, the flags I proposed go in exactly in the direction of displaying only a subset of the possible permutations for a given set of products. – kr1 Feb 28 '13 at 11:40

I have done something similar with Apache Solr and it's facets (that's more or less like tags). It's incredibly fast for counting the number of products for any combination.

You start with assigning useful facets to your products. Those can basically come in three forms:

single value: can have only one entry for a product, like gender or age group (baby, kid, adult) or brand.

multi value: can have several entries for a product like technical descriptions. Normally those are less interesting for menues, but in this case it may be interesting to show a product in several assortments like 'men' and 'outdoor' or whatever.

hierarchical: a bit complicated first. We use them for things like car_brand -> car_model -> built_year structures.

You can the ask Solr to begin with something like: "the gender facet must be 'male'" and the retrieve counts for all other facets and show those with a count > 0 as next level options. To some extend you can do this in real time (and combine that with full text search). Though for some areas we cache those query results, since creating a very deep structure can still take some time. (Even if you need to store those counts it's still far better to get them through this query interface than to write code that does the same counts manually.)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.