Created
April 3, 2014 20:14
-
-
Save kvnm/9962002 to your computer and use it in GitHub Desktop.
Find the last time drupal content of a particular content type or list of content types was updated (without views). Sometimes people like this kind of thing, apparently.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Returns a single "Last Updated" date. | |
* | |
* $types -- an array of content type machine names. Defaults to 'page'. | |
*/ | |
function custom_last_updated($types = array('page')) { | |
$query = db_select('node', 'n'); | |
$query | |
->condition('type', $types, 'IN') | |
->condition('status', 1, '=') | |
->fields('n', array('changed')) | |
->orderBy('changed', 'DESC') | |
->range(0, 1); | |
$result = $query->execute()->fetchField(); | |
$last_changed = '<div class="last-updated">Last Updated: ' . format_date($result, 'custom', 'l, F jS, Y') . '</div>'; | |
return $last_changed; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment