You are here

function i18n_book_navigation_nodeapi in Book translation 6.2

Same name and namespace in other branches
  1. 6 i18n_book_navigation.module \i18n_book_navigation_nodeapi()

Implementation of hook_nodeapi()

File

./i18n_book_navigation.module, line 77
Defines the i18n book navigation module. Contains all necessary data and hooks

Code

function i18n_book_navigation_nodeapi(&$node, $op, $teaser, $page) {
  switch ($op) {
    case 'view':

      // Check that we're not dealing with the original node itself or with a
      // non-translated node
      if ($node->nid != $node->tnid && $node->tnid != 0 && !$teaser) {

        // Get the original node book information
        $tnode = (object) array(
          'nid' => $node->tnid,
        );
        $book_info = book_nodeapi($tnode, 'load', $teaser, $page);

        // If the original node is part of a book outline
        if (!empty($book_info['book']['bid'])) {
          $node->content['book_navigation'] = array(
            '#value' => theme('i18n_book_navigation', $book_info['book']),
            '#weight' => 100,
          );
        }
      }
      break;
  }
}