Context sensitive sub-trees

Events happening in the community are now at Drupal community events on www.drupal.org.
pog21's picture

Hi,

Searched but didn't find this particular functionality being discussed. What I'm trying to do is use different parts of the same hierarchical vocabulary when creating 2 different content types.

The scenario is a simple directory where people can choose to post 'free' or 'premium' listings. The main difference between them being that free listings don't include certain categories and therefore can only select from a sub-tree of the vocab. As an example, in the following food hierarchy, 'fruit' and 'vegetables' are available in free listings, while 'fruit', 'vegetables' and 'cheese' are available in premium listings:

Vegetables
- Potatoes
- carrots
Fruit
- Apples
- Oranges
Cheese
- Cheddar
- Edam

So far I've done it with 2 content types (free-listing, premium-listing) and the content_taxonomy module, used to limit vocab to a sub-tree for the free listings creation page. However, in order to do this I needed to make an extra level in the hierarchy (i.e. parent terms for 'free' and 'premium'). I could then restrict the free-listing content type to the sub-tree 'free'. eg:

Free
- Vegetables
-- Potatoes
-- carrots
- Fruit
-- Apples
-- Oranges
Premium
- Cheese
-- Cheddar
-- Edam

However, I don't want the terms 'free' and 'premium' to appear when users search using hierarchical select. I also need the terms all in a single vocab so that users can search the directory as a single entity (or at least so it appears that way from the users perspective).

Does anyone know of a good way to achieve this?

I'm using drupal 6.19, content taxonomy 6.x-1.0-rc2.

Cheers,
Oliver

Comments

sorry I'm not much help, but

ginkgomzd's picture

sorry I'm not much help, but I think using the content types to gain the ability to restrict by permission settings is rather indirect.

I think you should be looking into how to modify the permissions system to set permissions for individual vocabularies. Maybe this already exists, I don't know.

Then I think you should use different vocabularies instead of sub-trees.

HTH, let us know how it ends up.

Hi Michael, Thanks for the

pog21's picture

Hi Michael,
Thanks for the reply and link. Vocabperms nearly does what I wanted, but doesn't appear to give control over creation of nodes with particular terms (only edit and view). I did, however, find a module: Taxonomy Access Control (http://drupal.org/project/taxonomy_access) which does all that I want, i.e. I can use the same taxonomy with different access settings in two different content types.

OK, so it was late when I

pog21's picture

OK, so it was late when I found the above module... and thinking about it now, with a (relatively) clear head, I realise the method I mentioned in the previous post would require that premium members could only create premium listings (otherwise they'd be able to access the premium terms when creating free listings) - which is not how it should work. Therefore what I need to do is to limit sections of the taxonomy based on the content type, not user permissions.
The Content Taxonomy module allows selections of single parent terms within a taxonomy. What is needed is the inverse of this - to be able to select all but one parent term (or be able to select a single parent term to ignore).
Found this thread, which seems related, http://groups.drupal.org/node/12738, but if anyone knows of a solution to this I'd be very interested to hear it.

Taxonomy

Group organizers

Group notifications

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