Drupal computed_field module code snippet

Drupal computed field code snippet for counting nodereferences - Addendum

When I first posted this, the sql query seemed to work fine, but after a bit of testing I noticed that node revisions will muck it. The query needed to get more complicated to look for the max vid instead of just relying on the nid. The symptom was that I would delete a nodereference, but it would still be counted (it would still count the previous revision's value). The revised computed field value is below.

Computed Field module asks us to add code snippets to the handbook pages, but they're nowhere to be found after the D6 upgrade. http://drupal.org/node/126522

Here's one that I just created to calculate the number of nodereferences for a cck type.

Background: 

CCK types
Venue
Event (includes datestamp field and is node referenced to Venue)

Syndicate content