Publication Date Update: module for Drupal 7 to add last update date to a node
Publication Date Update is a simple module for Drupal 7 that adds the "last update" date to a node, to be installed it needs the module Publication Date, because it works with the published_at variable.
Publication Date Update is simply this function:
function publication_date_update_preprocess_node(&$vars) {
$time_unit = 86400; // number of seconds in 1 day => 24 hours * 60 minutes * 60 seconds
$threshold = 10;
// --- Create revision data
// Check if node was revised
if (($vars['status']) && $vars['changed'] && (round(($vars['changed'] - $vars['published_at']) / $time_unit) > $threshold)){
$vars['submitted'] =
t('Published: !publishtime | Updated: !updatetime | Author: !username', array( '!publishtime' => format_date($vars['published_at'],'custom','d M Y'), '!updatetime' => format_date($vars['changed'],'custom','d M Y'), '!username' => $vars['name']));
} else {
$vars['submitted'] =
t('Published: !publishtime | Author: !username', array( '!publishtime' => format_date($vars['published_at'],'custom','d M Y'), '!username' => $vars['name']));
}
}
that could also be used as node preprocess function in template.php.
Attachment | Size |
---|---|
publication_date_update-7.x.zip | 1.04 KB |
Section:
Add new comment