By wflorian on
Hello.
I am look for a PHP Code to count the number of nodes assigned to a taxonomy term.
I just found the following code snippet: http://drupal.org/node/139934
Unfortunately this is for views but I need a normal PHP code which I could enter anywhere I would like.
Thanks in advance!
Regards Florian
Comments
You can use an API call
Try using taxonomy_select_nodes http://api.drupal.org/api/function/taxonomy_select_nodes/5
You'll get all the nodes, then just count them using some php code.
Doug Gough
ImageX Media
http://drupal.org/node/195034
http://drupal.org/node/195034 might be closer to what you're looking for though the node counting method would also work.
===
"Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime." - Lao Tzu
"God helps those who help themselves." - Ben Franklin
"Search is your best friend." - Worldfallz
Site map list terms and nodes assigned in parenthesis
The site map can display the following items:
* Any categories, i.e vocabulary, with all the terms expanded. Optionally with node counts and RSS feeds.
http://drupal.org/project/site_map
Thanks to all of you. I
Thanks to all of you.
I think the following code would be the best:
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)
Actually I am no PHP pro. How could I transform the code that it would fit my needs?
I have static page. On this page there are listed serveral taxonomy terms. Behind every term I want to post the nodecount. Means I don't need the PHP to be really dynamic. I would fill in the termid manually for every term...
Anybody any idea?
Thanks a lot again.
Regards.
Florian