Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Create a block with a list of categories and post count next to each, like in this example:
* Illustrator (35)
* InDesign (44)
* Photoshop (178)
* Quark XPress (4)
<?php
if (user_access('access content')) {
$result = db_query("SELECT term_data.tid, term_data.name, COUNT(*) AS count FROM {vocabulary_node_types} INNER JOIN {term_data} USING (vid) INNER JOIN {term_node} USING (tid) INNER JOIN {node} USING (nid) WHERE node.status = 1 and vocabulary_node_types.type = 'blog' GROUP BY term_data.tid, term_data.name ORDER BY term_data.name");
$items = array();
while ($category = db_fetch_object($result)) {
$items[] = l($category->name .' ('. $category->count .')', 'taxonomy/term/'. $category->tid);
}
return theme('item_list', $items);
}
?>
Comments
Drupal 6
In Drupal 6 just retype "blog" to "story":
...vocabulary_node_types.type = 'story'...
It did not work in my case.
It did not work in my case. I tested in in Drupal 6.12 and got the following error:
Any idea why this is happening?
I'm getting the same error as Chillz
Hi
I'm getting the same error as Chillz.
PHP is enabled
I have followed all the instructions and get the error.
Has anyone found a solution to this problem?
Is there a step I am missing?
I also tried it with "westwesterson's" code and get the same error.
Thanking anyone in advance
Daronna
This worked for me in drupal
This worked for me in drupal 6.13, make sure that you have php input filter enabled.
Also I tweaked this script slightly so that it would list terms by the count of taxonomy items. And limited to 25 terms.
Catagories should now show up as:
* Photoshop (178)
* InDesign (44)
* Illustrator (35)
* Quark XPress (4)
How can we also show the
How can we also show the number of comments the term has in the nodes tagged with it.
There's a Taxonomy block
There's a Taxonomy block module that does this perfectly
It works nice for me on
It works nice for me on Drupal 6.14. But I was wondering instead of terms, can I show number of nodes in a whole vocabulary?
I mean instead of:
Austria(5)
Angola(2)
Australia(8)
I need:
Countries(15)
I have just found a solution
I have just found a solution if anyone needs:
hello. I use the drupal 6.15
hello. I use the drupal 6.15 with easyphp 5.3 and also i have enable the php code. When i run the above code i get the message
Parse error: parse error in C:\Program Files\EasyPHP5.3.0\www\drupal\includes\common.inc(1685) : eval()'d code on line 3
Any help is wellcome
thanks
--Kostas--
Limiting the number of taxonomy by date
Hi,
how can i limit the shown number of taxonomy to the last 24 hours