summaryrefslogtreecommitdiff
path: root/modules/book
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-09-18 10:54:20 +0000
committerDries Buytaert <dries@buytaert.net>2009-09-18 10:54:20 +0000
commit2bc3de6a4ffa99e47ddfd05fbe75927c882412d4 (patch)
treea3a0791dd35ca89f838a5ffb26eea560e7d4b9c5 /modules/book
parentdf02fa3ca46e16974192de77580762188ad47f49 (diff)
downloadbrdo-2bc3de6a4ffa99e47ddfd05fbe75927c882412d4.tar.gz
brdo-2bc3de6a4ffa99e47ddfd05fbe75927c882412d4.tar.bz2
- Patch #283723 by pwolanin, sun | eddified, moshe weitzman, Dries, aether, Arancaytar: Added Make menu_tree_output() return renderable output.
Diffstat (limited to 'modules/book')
-rw-r--r--modules/book/book-all-books-block.tpl.php7
-rw-r--r--modules/book/book.module26
2 files changed, 27 insertions, 6 deletions
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.
*/
?>
<?php foreach ($book_menus as $book_id => $menu) : ?>
<div id="book-block-menu-<?php print $book_id; ?>" class="book-block-menu">
- <?php print $menu; ?>
+ <?php print render($menu); ?>
</div>
<?php endforeach; ?>
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)) : '';
}
/**
@@ -892,6 +893,27 @@ function _book_link_defaults($nid) {
}
/**
+ * 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.
*
* The $variables array contains the following arguments: