function internal_nodes_node_load in Internal Nodes 7
Implements hook_node_load().
File
- ./
internal_nodes.module, line 371 - Internal nodes
Code
function internal_nodes_node_load($nodes, $types) {
// Get the per-node settings if a relevant bundle is set to allow per-node
$result = array();
foreach ($nodes as $node) {
if (variable_get('internal_nodes_nodes_' . $node->type, 0)) {
$result = db_query('SELECT * FROM {internal_nodes} WHERE nid IN(:nids)', array(
':nids' => array_keys($nodes),
))
->fetchAllAssoc('nid');
break;
}
}
foreach ($nodes as &$node) {
// If action exists in the result
if (isset($result[$node->nid]->action) && $result[$node->nid]->action != 0) {
$node->internal_nodes['source'] = 'node';
$node->internal_nodes['action'] = $result[$node->nid]->action;
$node->internal_nodes['url'] = $result[$node->nid]->url;
}
else {
// Action not in results, use content type settings
$node->internal_nodes['source'] = 'content_type';
$node->internal_nodes['action'] = variable_get('internal_nodes_action_' . $node->type, INTERNAL_NODES_FOUND);
$node->internal_nodes['url'] = variable_get('internal_nodes_url_' . $node->type, '');
}
}
}