Hi all,

How can I create a view of taxonomy terms and display it to a block with parent and child relationship, like this http://chameabbey.com/

And how can I add a count per term, in Drupal 6 we can add a relationship to a node then add an argument of term(ID) and a style of list then "Display record count with link". But how I can dothis in Drupal 7 with parent child relationship.


Fruits (5)
- Apple (3)
- Banana (2)
Vegetables (4)
- Beans (1)
- Eggplant (2)
- Onions (1)



dinathecool’s picture

in drupal 7 you can add views term page

in views default Taxonomy term views page is available but you need to enable it and configure it as per your needs

or go to view->add new view
give title and in Show field select Taxonomy terms options and select the type and other info etc.. and click save
you created the taxonomy page

darrylmabini’s picture

Hi Sir thank you for the response.

I already tried that but it will only display all the terms without indention and without (count). I need a hierarchical display of all the terms.

If I go to structure>Taxonomy - Drupal 7 has the default vocabulary called "Tags" and if I add terms on that vocabulary below there's a collapsed fieldset called "Relations" and I want to display the taxonomy terms hierarchically base on that relations.

I already got the solution to count the nodes per term -> this can be done by adding a relationship "Content: Taxonomy terms on node" and then add a Contextual filters "Taxonomy term: Name" -> display a summary -> display record count with link.

Like in my previous example, I need something like this but I can't figure it out how:
Parent 1 (2)
- child1 of parent 1 (1)
- child2 of parent 1 (1)
Parent 2 (1)
- child1 of parent 2 (1)

I can create a custom module just to for this, but I think this can be done in views I just don't know how to configure it.


iRex’s picture

@darrylymabini - I am having a similar problem; did you ever find the solution to this?

... so I said to the Captain, please bring me my wine...

adam_b’s picture

I've never managed this in D7 Views either.

The only way I've found to do it is with http://drupal.org/project/taxonomyblocks which works to some extent but has limitations (and the D7 version is still in development).

hershy.k’s picture

I think I am trying to figure out a similar scenario to your comment. How to display the count number of the node using the taxonomy term. Like having a list of content nodes that all use taxonomy term name of "cities" and it should display 'node 1 of cities', 'node 2 of cities' etc.

Did you figure out how to get that with views?

charubachi’s picture

I want to show the parent for the child term in taxonomy display

Charubachi Rath

calmher’s picture


I am the owner of the website http://chameabbey.com/ and I'm sorry if it took a while for me to discover this entry, but let me show you what worked for me. I didn't use any modules on this (although the Taxonomy Menu module could work too!), instead I created a block with php code input format.

For Drupal 6, I got this snippet:

As for Drupal 7, I just needed to tweak the code a bit to this:

if ( ! function_exists('private_get_children') ) {
private_get_children($vid, $parent = 0) {
$items = array();
$terms = taxonomy_get_tree($vid, $parent, $max_depth = 1, $load_entities = FALSE);
        foreach (
$terms as $term ) {
$count = count(taxonomy_select_nodes($term->tid)) == 0 ? ' ' : '(' . count(taxonomy_select_nodes($term->tid)) . ')';
$items[] =  l($term->name, "taxonomy/term/$term->tid") . " $count" . private_get_children($vid, $term->tid);
        if (
count($items) ) {
theme('item_list', array('items' => $items));

$vid = 6// Set the vid to the vocabulary id of the vocabulary you wish to list the terms from

print private_get_children($vid);

Note that in D7, instead of using db_query(), I used taxonomy_select_nodes() to count the number of nodes in a given term.

Hope that helps!


melly.prasanna’s picture

hi all,

i was looking for a similar display of the taxonomy term, I found that the Taxonomy menu block can achieve this.
when configuring the settings choose the vocabulary and click on the extra->check the options "display node count" & "aggregate the child node count". Hope this helps.