function publication_date_node_load in Publication Date 7
Same name and namespace in other branches
- 7.2 publication_date.module \publication_date_node_load()
Implements hook_node_load().
File
- ./
publication_date.module, line 11 - Add a field to nodes containing the publication date.
Code
function publication_date_node_load($nodes, $types) {
foreach ($nodes as $node) {
$node->published_at = _publication_date_get_date($node->nid);
// We have to manage the 'old nodes', i.e nodes that have been published
// BEFORE the activation of this module.
if (!$node->published_at) {
$row = db_select('node', 'n')
->fields('n', array(
'created',
'status',
))
->condition('nid', $node->nid)
->execute()
->fetchAssoc();
if ($row && $row['status'] == 1) {
$node->published_at = $row['created'];
}
}
}
}