Commit b2eef2db authored by git's avatar git Committed by Nicholas Thompson
Browse files

Fixing issue #1377484 - run single query to fetch multiple items on node_load.

parent b495dfa5
...@@ -357,10 +357,17 @@ function page_title_node_type_form_submit($form, &$form_state) { ...@@ -357,10 +357,17 @@ function page_title_node_type_form_submit($form, &$form_state) {
* Implement hook_node_load(). * Implement hook_node_load().
*/ */
function page_title_node_load($nodes) { function page_title_node_load($nodes) {
foreach ($nodes as $node) { $nids = array();
if ($page_title = page_title_load_title($node->nid, 'node')) {
$node->page_title = $page_title; // Get a list of node nids to fetch page_title's later
} foreach ($nodes AS $node) {
$nids[] = $node->nid;
}
// Fetch page_title information from database and assign it to nodes
$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