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.
I'd like to count the number of nodes that the node might reference as well as the total number of nodes referencing that node - all together. How can this be accomplished?
Comments
Comment #1
gilgabar CreditAttribution: gilgabar commentedNodereference count will give you the number of nodes referencing a given node.
The number of nodes that particular node references can be found in the node object. Make sure devel module is installed and do a dsm($node) from someplace where the node object is available (node.tpl.php is probably a reasonable place) and then you can drill down into the node object and find your node reference field. You should be able to do a count() on that array to get the total number of references.
To get the grand total of those two things just add them.
Comment #2
gilgabar CreditAttribution: gilgabar commentedMarking this closed, please re-open if that didn't answer your question adequately.
Comment #3
Nicolas Bouteille CreditAttribution: Nicolas Bouteille commentedHi,
I personally don't need this right now but I read the request and I think even though I agree that the php solution is pretty simple, it would be nice to provide the feature. Don't you think?
Switching this to a minor feature request.