Advertising sustains the DA. Ads are hidden for members. Join today

Computed Field

Major Revision Only Timestamp

Last updated on
30 April 2025

We ran into a scenario where we needed to sort nodes by the last MAJOR revision timestamp (ie. only when they ticked the Revision checkbox). We created a new computed field that generates a new timestamp when a node is first created and only updates the timestamp if the Revision checkbox is ticked. This new CCK field is then exposed to the Views module to allow sorting by this timestamp instead of the $node->changed value.

Here is the simple snippet placed in the computed code field:

if ($node->is_new || $node->revision) {
  $node_field[0]['value'] = time();
}

nrambeck

Help improve this page

Page status: Not set

You can: