From 2bc3de6a4ffa99e47ddfd05fbe75927c882412d4 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Fri, 18 Sep 2009 10:54:20 +0000 Subject: - Patch #283723 by pwolanin, sun | eddified, moshe weitzman, Dries, aether, Arancaytar: Added Make menu_tree_output() return renderable output. --- modules/book/book-all-books-block.tpl.php | 7 +++---- modules/book/book.module | 26 ++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 6 deletions(-) (limited to 'modules') diff --git a/modules/book/book-all-books-block.tpl.php b/modules/book/book-all-books-block.tpl.php index daec0aa82..5a42c9835 100644 --- a/modules/book/book-all-books-block.tpl.php +++ b/modules/book/book-all-books-block.tpl.php @@ -8,13 +8,12 @@ * all pages" which presents Multiple independent books on all pages. * * Available variables: - * - $book_menus: Array of book outlines rendered as an unordered list. It is - * keyed to the parent book ID which is also the ID of the parent node - * containing an entire outline. + * - $book_menus: Array of book outlines keyed to the parent book ID. Call + * render() on each to print it as an unordered list. */ ?> $menu) : ?>
- +
diff --git a/modules/book/book.module b/modules/book/book.module index 13a589c45..2df5e988f 100644 --- a/modules/book/book.module +++ b/modules/book/book.module @@ -248,7 +248,8 @@ function book_block_view($delta = '') { $book_menus[$book_id] = menu_tree_output($pseudo_tree); } } - $block['content'] = theme('book_all_books_block', $book_menus); + $book_menus['#theme'] = 'book_all_books_block'; + $block['content'] = $book_menus; } elseif ($current_bid) { // Only display this block when the user is browsing a book. @@ -705,7 +706,7 @@ function book_children($book_link) { } } - return $children ? menu_tree_output($children) : ''; + return $children ? drupal_render(menu_tree_output($children)) : ''; } /** @@ -891,6 +892,27 @@ function _book_link_defaults($nid) { return array('original_bid' => 0, 'menu_name' => '', 'nid' => $nid, 'bid' => 0, 'router_path' => 'node/%', 'plid' => 0, 'mlid' => 0, 'has_children' => 0, 'weight' => 0, 'module' => 'book', 'options' => array()); } +/** + * Process variables for book-all-books-block.tpl.php. + * + * The $variables array contains the following arguments: + * - $book_menus + * + * All non-renderable elements are removed so that the template has full + * access to the structured data but can also simply iterate over all + * elements and render them (as in the default template). + * + * @see book-navigation.tpl.php + */ +function template_preprocess_book_all_books_block(&$variables) { + // Remove all non-renderable elements. + $elements = $variables['book_menus']; + $variables['book_menus'] = array(); + foreach (element_children($elements) as $index) { + $variables['book_menus'][$index] = $elements[$index]; + } +} + /** * Process variables for book-navigation.tpl.php. * -- cgit v1.2.3