function page_title_node_load in Page Title 8.2
Same name and namespace in other branches
- 7.2 page_title.module \page_title_node_load()
- 7 page_title.module \page_title_node_load()
Implement hook_node_load().
File
- ./
page_title.module, line 359 - Enhanced control over the page title (in the head tag).
Code
function page_title_node_load($nodes) {
$nids = array();
// Get the settings
$settings = page_title_get_settings();
// Get a list of node nids to fetch page_title's later
foreach ($nodes as $node) {
// Check the node type has the 'Show Field' enabled, otherwise there is no point querying for the data
if (isset($settings['page_title_type_' . $node->type]) && $settings['page_title_type_' . $node->type]['show field']) {
$nids[] = $node->nid;
}
else {
$nodes[$node->nid] = '';
}
}
// If we have ended up with no nodes to load titles for, lets not query...
if (empty($nids)) {
return;
}
// Fetch page_title information from database and assign it to nodes
// TODO - Can we make this better? IN() queries dont scale welll..
$result = db_query('SELECT page_title, id FROM {page_title} WHERE type = :type AND id IN (:nids)', array(
':type' => 'node',
':nids' => $nids,
));
foreach ($result as $record) {
$nodes[$record->id]->page_title = $record->page_title;
}
}