I want to create a list of category terms (contained within a block), with each term to be followed by a count of the number of nodes with that term, e.g.:
Cats (5)
Dogs (4)
Elephants (2)
There are a number of modules that create whole lists like this dynamically, but I've found they all have drawbacks for my purposes. I literally just need something like this:
<ul>
<li><a href="mylink">Cats</a> (<?php ...some code... ?>)</li>
<li><a href="mylink">Dogs</a> (<?php ...some code... ?>)</li>
<li><a href="mylink">Elephants</a> (<?php ...some code... ?>)</li>
</ul>
I.e. I only need the count to be dynamic, not the whole list (this is OK because the terms themselves will not change).
I've heard that the Drupal function taxonomy_term_count_nodes()
may be useful, but I can't find any simple information regarding its implementation.