The conversion to Field API caused taxonomy_term_count_nodes() to be removed form the API. A lot of contributed modules depend on this function and a lot of users want this feature. Because it used to exist I am marking this a bug.
The conversion to Field API caused taxonomy_term_count_nodes() to be removed form the API. A lot of contributed modules depend on this function and a lot of users want this feature. Because it used to exist I am marking this a bug.
Comments
Comment #1
Anonymous (not verified) commentedI'm not a big fan of this idea, but I sympathize with the potential frustration of its loss. I wonder if this isn't a call to have a "legacy" module where these functions can be placed. I wouldn't want contrib maintainers to write the same code over and over again because this function has disappeared.
A lot of modules also read $node->taxonomy, which has the convenience of being an array of all terms in all vocabularies for a node. In Drupal 7, we will have to determine which field instance on this bundle has a term's vocabulary in its allowed values. Should we put $node->taxonomy back, too?
If we do restore it, I want to ask: Why should it only count nodes? because it's what Drupal 6 modules expect?
Comment #2
giorgio79 commentedhttp://drupal.org/project/term_node_count
This project has views integration etc etc :)
Although a CCK Count module would be cool where we can select the table, or the column for which we want to maintain a summary table :)
Comment #3
catchThe proper way to fix this would be #603236: Add count facility to field_attach_query(). There's not much time before freeze but let's explore that before we revert here - whether it's a contrib helper module or a core patch.
Comment #4
catchBetween #603236: Add count facility to field_attach_query() and http://drupal.org/project/term_node_count there's an ability to get the count in core, and a module implementing what looks to be a nice performant lookup table in contrib (and which should be able to use field hook and field_attach_query() to do what it's doing in D6). So marking this as a duplicate of those two.
I also opened #603868: Rework Term Node Count for D7.
Comment #5
antroxim commentedHi everyone!
It's my first comment at drupal.org and my first "drupal-custom-functioning" experience.
I wrote a simplest function to count nodes by term ID.
Hope someone find it useful.
Comment #6
Avorathol commentedAn improvement of #5, with some recursion to take account of hierarchical children.
Comment #7
cegri commentedSome tweaks on #6:
1) Modified the handling of the recursive sub-function. I was getting "call_time_pass_reference" errors.
2) Added language criteria. Only nodes in the current language and neutral language (undefined) are counted.
Note: I'm not a programmer. I go around copying, pasting and tweaking others' codes. So, use cautiously. Any improvements are wellcome.
Comment #8
leofishman commentedThanks!!