Last updated January 22, 2009. Created by nrambeck on January 22, 2009.
Log in to edit this page.
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:
<?php
if ($node->is_new || $node->revision) {
$node_field[0]['value'] = time();
}
?>