views:

61

answers:

2

In Drupal I have the page content type. I have created a vocublary and the terms in it make a heirachy as below:

  • Bird
  • Mammal
    • Dog
      • Poodle
      • bulldog
    • Cat
      • Tiger
    • Rabbit
  • Reptile
    • Lizard

I select the term when I create a content type. I wish to display all the pages that have have this conent type in a menu (unordered list) maintating the heirachy above. Is this possible? Which modules would you use to do this?

+1  A: 

You could use the taxonomy_menu module.

The module page: http://drupal.org/project/taxonomy_menu

This module renders a vocabulary into a menu. If this is not what you need (e.g. if you want to display ths vocabulary in a node content), I think you have to write a simple module for it that gets triggered in hook_nodeapi().

schneck
The module does not seem to do what I need so looks like I may need to write soemthing for myself.
Rupert
What doesn't it do that you need?
Mike Crittenden
OP wants the nodes themselves to be displayed in a tree, not a menu of the terms in a tree.
googletorp
I wrote a simple module to do this
Rupert
+1  A: 

With the views you would be able to get very far in this matter, but I'm not sure if it is worth it in this case. The thing with views, is that it can be a bit tricky to generate the markup you want. With views it's possible to create any kind of markup you want, and make it display whatever you want. However, sometimes the work required to get there is not worth it vs just making your own module to do it.

You should try to look into views first and see if you can get what you want.

If you're not able to get what you want, I think creating your own custom module is the way to go. I don't know if there is an api function to get the nodes, but it should pretty simple query required to get them. Then you have the power you create the markup exactly how you want. You could just create a theme function to do all this that you can call in your theme.

googletorp
With views it does not seem possible for me to keep the structure of my content type. Maybe I am going about this the wrong way...
Rupert
I thought that would be the case, but it was worth checking. Easiest thing to get what you want is making a small custom module to do the task.
googletorp
Personaly I think the menu root we are going is wrong I will have a think and see if I can come up with something better.
Rupert

related questions