diff options
-rw-r--r-- | modules/book.module | 8 | ||||
-rw-r--r-- | modules/book/book.module | 8 |
2 files changed, 12 insertions, 4 deletions
diff --git a/modules/book.module b/modules/book.module index 37b9a2352..1e2a77979 100644 --- a/modules/book.module +++ b/modules/book.module @@ -454,11 +454,14 @@ function book_toc($parent = 0, $indent = "", $toc = array()) { function book_tree_recurse($nid, $depth, $children) { - if ($depth > 1) { + if ($depth > 0) { if ($children[$nid]) { foreach ($children[$nid] as $foo => $node) { $output .= "<li><a href=\"node.php?id=$node->nid\">". check_output($node->title) ."</a></li>"; - $output .= book_tree_recurse($node->nid, $depth - 1, $children); + + if ($tree = book_tree_recurse($node->nid, $depth - 1, $children)) { + $output .= "<ul>$tree</ul>"; + } } } } @@ -476,6 +479,7 @@ function book_tree($parent = 0, $depth = 3) { array_push($list, $node); $children[$node->parent] = $list; } + $output = book_tree_recurse($parent, $depth, $children); $output = "<ul>$output</ul>"; diff --git a/modules/book/book.module b/modules/book/book.module index 37b9a2352..1e2a77979 100644 --- a/modules/book/book.module +++ b/modules/book/book.module @@ -454,11 +454,14 @@ function book_toc($parent = 0, $indent = "", $toc = array()) { function book_tree_recurse($nid, $depth, $children) { - if ($depth > 1) { + if ($depth > 0) { if ($children[$nid]) { foreach ($children[$nid] as $foo => $node) { $output .= "<li><a href=\"node.php?id=$node->nid\">". check_output($node->title) ."</a></li>"; - $output .= book_tree_recurse($node->nid, $depth - 1, $children); + + if ($tree = book_tree_recurse($node->nid, $depth - 1, $children)) { + $output .= "<ul>$tree</ul>"; + } } } } @@ -476,6 +479,7 @@ function book_tree($parent = 0, $depth = 3) { array_push($list, $node); $children[$node->parent] = $list; } + $output = book_tree_recurse($parent, $depth, $children); $output = "<ul>$output</ul>"; |