Hi,

Can you please let me know how I show the taxonomy tree widget as a block on any page based on vocabulary id.

I want to show the complete tree structure as a block.

Please help me.

I really want to use this tree widget.

Thanks in advance

Vikas

Comments

bartk’s picture

Status: Active » Closed (works as designed)

The tree widget is intended to display the contents of a field, not the entire contents of a taxonomy tree. What you're asking for is outside the scope of this module, and would need to be done with a custom coded block.

cis_dream’s picture

I'm asking about is that possible to generate the tree according to vocabulary id. There is any function available to achieve this task.

Just want to generate tree like structure of any vocabulary and display them as a block on any page of the site.

is this possibel??

bartk’s picture

Yes, this is very doable in PHP, but you'll need to create your own module to do it.

The function _term_reference_tree_get_term_hierarchy in my module loads the tree structure, although it does a bunch of extra stuff that you probably wouldn't care about. You can also use the taxonomy_get_tree function in the API, which I personally don't like because it returns a flat array with a depth and is a bit harder to work with, but should still work for usable for what you're trying to do.

Regardless, in your block rendering function, you could just iterate through the tree (or the list) and print out the HTML for the taxonomy terms.