0

My task is to display all the terms in a particular vocabulary. It should also display all the sub-terms along with their parent terms.

For example the taxonomy page for a particular vocabulary is like

Term 1

Term 2

Term 3

Sub-term 1 of Term 3

Sub-term 2 of Term 3

Sub-term 3 of Term 3

Term 4

Term 5

Term 6

Sub term 1 of Term 6

Sub term 2 of Term 6

I need an exact display of taxonomy terms as above (without edit, just to list all the terms in a tree order). Is it possible with views or whether I have to do coding? I tried this thing with views by giving term- weight filter, taxonomy parent term relationships etc, received duplicate values and found it very complex.

2

You can use taxonomy_get_tree()

Parameters

$vid: Which vocabulary to generate the tree for.

$parent: The term ID under which to generate the tree. If 0, generate the tree for the entire vocabulary.

$depth: Internal use only. Now deprecated and isn't used. It is left here only because of compatibility issues.

$max_depth: The number of levels of the tree to return. Leave NULL to return all levels.

API here

  • Thank you very much. I made it with taxonomy_get_tree(). – Anson Apr 18 '12 at 9:29
  • @Anson consider choosing the correct answer. – niksmac Apr 18 '12 at 9:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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