You are here

function book_helper_action in Book helper 7

File

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

Code

function book_helper_action($node, $context = array()) {
  if (isset($context['book'])) {

    // The selected value from the form is the mlid of the page we want
    // as the parent of this page - i.e. its plid.
    $plid = $context['book'];

    // Use this to lookup the bid in the book table.
    $bid = db_select('book', 'bk')
      ->condition('bk.mlid', $plid)
      ->fields('bk', array(
      'bid',
    ))
      ->execute()
      ->fetchField();
    $node->book['bid'] = $bid;
    $node->book['plid'] = $plid;
    $node->book['module'] = 'book';
    _book_update_outline($node);
    menu_cache_clear_all();
  }
}