Community Documentation

Major Revision Only Timestamp

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();
}
?>

nrambeck

About this page

Drupal version
Drupal 5.x

Site Building Guide

Drupal’s online documentation is © 2000-2013 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.
nobody click here