Hi,

I have several books on my site with 3 and 4 levels. Example:

  • Practices
    • Mahavidyas
      • Matangi
      • Bagalamukhi
    • Body practices
      • Asanas
        • First
        • Second

On the sitemap page, they were expanded only for 2 levels. Items 'Mahavidyas' and 'Body practices' were rendered as collapsed and data analysis showed there were no children returned for them by the function menu_tree_all_data(). This was caused by supplying second parameter "$node->book". After I removed it, entire book was expanded correctly:

/**
 * Render books
 */
function _site_map_books() {
  $output = '';
  if (module_exists('book') && ($nids = variable_get('site_map_show_books', array()))) {
    $title = t('Books');
    $description = '<div class="description">'. t("Books at %sn.", array("%sn" => variable_get('site_name', 'Drupal'))) .'</div>';

    $book_menus = array();
    foreach ($nids as $nid) {
      $node = node_load($nid);
      /*
	   // kettari 14.05.2010: removed second arg to expand entire book
	   $tree = menu_tree_all_data($node->book['menu_name'], $node->book);
	   */
	  $tree = menu_tree_all_data($node->book['menu_name']);
      $data = array_shift($tree);
      $output .= theme('book_title_link', $data['link']);
      $output .= ($data['below']) ? menu_tree_output($data['below']) : '';
    }

    if ($output) {
      $output = theme('site_map_box', $title, $description . $output, 'sitemap-book');
    }
  }

  return $output;
}

So I propose to review this issue and looking forward for feedback from maintainers or contributors.

Comments

frjo’s picture

Status: Needs review » Closed (duplicate)

This has already been committed to 6.x-2.x-dev, se #761218: PATCH SUGGESTION: Fix book module depths.