You are here

function book_helper_node_load in Book helper 7

Implements hook_node_load().

File

./book_helper.module, line 162
Improves Drupal's core book module's functionality.

Code

function book_helper_node_load($nodes, $types) {

  // Track customized link title and whether it is sync (equal) to the node's title.
  $query = 'SELECT nid, link_title FROM {book} b INNER JOIN {menu_links} ml ON b.mlid = ml.mlid WHERE b.nid IN(:nids)';
  $args = array(
    ':nids' => array_keys($nodes),
  );
  $result = db_query($query, $args);
  foreach ($result as $record) {
    if ($record->link_title) {
      $node_title = function_exists('node_parent_title_remove') ? node_parent_title_remove($nodes[$record->nid]->title) : $nodes[$record->nid]->title;
      $nodes[$record->nid]->book_helper = array(
        'link_title_custom' => $record->link_title,
        'link_title_sync' => $record->link_title == $node_title,
      );
    }
  }
}