You are here

function i18n_book_navigation_node_view in Book translation 7.2

Implements hook_node_view().

2 calls to i18n_book_navigation_node_view()
i18n_book_navigation_ctools_render_alter in ./i18n_book_navigation.module
Implements hook_ctools_render_alter().
i18n_book_navigation_i18n_book_nav_content_type_render in plugins/content_types/i18n_book_nav.inc
Implements hook_PLUGIN_content_type_render().

File

./i18n_book_navigation.module, line 38
Defines the Book translation module.

Code

function i18n_book_navigation_node_view($node, $view_mode = 'full') {
  if ($view_mode == 'full') {

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

        // Get the original node book information.
        $tnode = (object) array(
          'nid' => $node->tnid,
        );
        book_node_load(array(
          $node->tnid => $tnode,
        ), array());
      }
      else {

        // In the case of field translation tnid is zero.
        // We work with nid instead.
        $tnode = (object) array(
          'nid' => $node->nid,
        );
        book_node_load(array(
          $node->nid => $tnode,
        ), array());
      }

      // If the original node is part of a book outline.
      if (!empty($tnode->book['bid'])) {

        // Set the breadcrumb.
        i18n_book_navigation_set_breadcrumb($node, i18n_book_navigation($tnode));

        // Add the book navigation.
        $node->content['book_navigation'] = array(
          '#markup' => theme('i18n_book_navigation', $tnode->book),
          '#weight' => 100,
        );
      }
    }
  }
}