Cross vocabulary hierarchy

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
OnkelTem's picture

Hi all,

Is there a way to make vocabularies hierarchically dependent, so that their terms would inherit this hierarchy?

Example:

voc 1: Countries
  voc 2: Cities
    voc 3: Theaters

Now for tagging an event we first select Country, then City, then Theater.
I found no solution for this on D5, now I'm on D6.
Any ideas (patches are welcome too)?

And, of course, having this working together with http://drupal.org/project/hierarchical_select would be great.

p.s. Thing which is not an option - placing terms in one vocab.

Comments

Try Hierarchical_Select

wilmar81's picture

Hi!

Yes, this is possible with Drupal no matter 5 or 6.

Here's how i did it. I created a voc regions and linked this voc with the right content types (hope you know how to do this). Then, inside the voc, add any term, assuming the first level is your Country, the second your city and the third your theater (you can add as many sub terms as you want).

An example would be:
Vocabulary: Regions

<em>Inside regions</em>
Usa
  Chicago
    16th Street Theater
    Actors Gymnasium
  New-York
    13th Street Repertory Theater
    Alice Tully Hall
France
  Paris
    Théâtre des Champs-Élysées
    Opéra Comique
    Comédie Française
  Marseille
    Creuset des arts
    L'Intermédiaire

The default behaviour of taxonomy doesn't make it possible to select a Theater after you selected the City and the Country. Here's where hierarchical select helps. Download and install the module. Only Hierarchical Select and Hierarchical Select Taxonomy are available to use inside the module. And they are enough to help.

Once you've installed them all, update the voc we created upper (regions), and select Use the Hierarchical Select form element for this vocabulary. Below there are many options you can use, depending on how you want hierarchical_select to function.

Wish I helped.

;) Then you title must be: Cross term hierarchy.

Cheers!


Life worth it to live. No matter what you're going through. Only your weakness can overcome your strenght.
http://www.bamena.com/
http://www.actumaroc.info/

--Willy

Life worth it to live. No matter what you're going through. Only your weakness can overcome your strenght.

--Sites
http://www.telecomaroc.com/
http://www.squaresystems.co.ma/

Thanks, wilmar81 for

OnkelTem's picture

Thanks, wilmar81 for reply!

Yes, I understand your approach and considered this too.
Unfort. this is not an option for me, as I mentioned in P.S., for reasons.

One disadvantage of this is that countries, cities and theaters - are of different "types". If we want later, for example, to create a database of theaters, binding every theater-tag to a node ( http://drupal.org/project/taxonomy_node ) we will get a problem, since we have no theaters voc. , instead we have our tree. And I see no simple way, for example, to determine of which type an arbitrary term is? (By level?)

Another problem - having theaters in Cities, makes Cities having only theaters in them - not companies, stadiums, whatsoever. Or, having cities right into Countries, we can't create anything else inside them. Otherwise things of different types will mess up.

Hack it.

bangpound@drupal.org's picture

OnkelTem, your problem has a variety of solutions. They're not easy ones though...

First of all, countries and cities are not different things. They are toponyms (place names), and they can be represented as parent-child relationships (city is contained in country / country contains city) as dictated by administrative and bureaucratic entities like sovereign nation states and the law. All "things" in this vocabulary have a latitude and longitude. You could stretch this vocabulary to include theaters and other venues because these all also have latitude and longitude, but this is where you lose detail about what kind of things these are.

In Drupal 6, there's no good way to add more detail to taxonomy vocabularies except through hierarchy and relationships. While a vocabulary like "Geonames" will tell you that New York City is a city and the Trocadero is a cultural "spot." It's not easy to capture this information in Drupal until Drupal 7.

I don't know the full architecture of your site, but I think you could get somewhere by making theaters and venues into nodes of the same type. Use your vocabulary to classify these nodes for their city and country. Then when you create events, you will need a node reference field and a custom widget (or any of the contrib widgets that work for Node Reference field) that lets you link to a theater but also lets you narrow the selection on the node form using the toponym vocabulary. Likewise, the CCK node reference field formatter could be extended to display the city and country of the venue when the event node is displayed.

There may be other solutions people can propose, too.

I'm sorry it's not a simple answer! However, your instincts are mostly right to avoid merging your places with your venues. I think it's safe to merge country and city.

Hi, I'm very interested about

lor's picture

Hi,

I'm very interested about this question too.
One of the most interest than I thought about this strategy to organize taxonomy is to give to the admins of the website a simple way to add sub-menus, for example.

Ex:
Imagine Countries are the principal menu of our website (primary links, for example).
The sub-menu for each country are towns.
The number of countries is defined and "locked", to preserve our principal navigation.
The towns are not exhaustive and other towns can be added.
We could have a "fixed" vocabulary for countries, not accessible by the admins.
And a accessible vocabulary for towns (via a cck or taxonomy field), which could be "attached" to a country, which is a term of the countries vocabulary.
By tags, admins could add a new town which become a new sub-menu of the country menu on which it is associated.

Do you know a possibility to associate a vocabulary to a term of another vocabulary and create a hierarchy between them ?

loR

i have this kind of problem to..

Adscreed's picture

in my case i am trying to create a classified ads site.. since it needs to be classified by term i try to create 8 vocabularies with different terms each.. i want users to select a certain vocabulary, after they selected the vocabulary a list of terms of that vocabulary will show up.. and they should select atleast 1 term..
now my question. how can i do these?

Same type of problem

giacinlui80's picture

Hi,

I too have the same problem of Adscreed: I would like in the node creation form the user can choose between different vocabularies, and only after choosing one of these to choose one of the words inside. Is there a solution?

Combining HS with a node

fuzzyjared's picture

Combining HS with a node taxonomy cck field should accomplish that

Thanks for the reply but

giacinlui80's picture

Thanks for the reply but please could you be clearer? What do you mean by "Combining HS with a taxonomy node cck field?

Hierarchical Select and Content Taxonomy

fuzzyjared's picture

http://drupal.org/project/hierarchical_select
http://drupal.org/project/content_taxonomy

Create a vocabulary and subsequent term structures.

Using CCK create a content taxonomy field that utilizes the Hierarchical Select (HS) for the widget type.

Configure the content taxonomy to start with the vocabulary that you just set up.

And that is pretty much it... there are some setup options for the field that you can set with the HS field, but that should be sufficient to get you on your way.

Look at the HS project page for more details.

Thanks again for the help

giacinlui80's picture

Thanks again for the help you're giving me.

Unfortunately your solution does not solve the problem because the content taxonomy requires a vocabulary from which to choose the terms. Instead I need a user in the node creation form, can first choose one of available vocabularies and only after this choice, select the terms of that vocabulary!

I see what you are

fuzzyjared's picture

I see what you are saying.

Would it work for your needs to handle it in a single vocabulary?

I have done something similar where I have a single vocab and then pair items out from there. Though this isn't the right fit for all cases it might be for yours.

I will likely be working on trying to get something like you have described in the future. If I do I will post it.

Ok Thanks for everything

giacinlui80's picture

Ok Thanks for everything

Relationships & site structuring

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week