Commit a1f983d8 authored by Nicholas Thompson's avatar Nicholas Thompson
Browse files

Improving the page_title_node_load() implementation by only loading titles for...

Improving the page_title_node_load() implementation by only loading titles for nodes which have show field enabled on them.
parent b2eef2db
......@@ -359,12 +359,28 @@ function page_title_node_type_form_submit($form, &$form_state) {
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) {
$nids[] = $node->nid;
// 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;
}
// Otherwise, set a blank value on the node
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;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment