function _book_toc_recurse in Drupal 7
Same name and namespace in other branches
- 6 modules/book/book.module \_book_toc_recurse()
Recursively processes and formats menu items for book_toc().
This helper function recursively modifies the table of contents array for each item in the menu tree, ignoring items in the exclude array or at a depth greater than the limit. Truncates titles over thirty characters and appends an indentation string incremented by depth.
Parameters
$tree: The data structure of the book's menu tree. Includes hidden links.
$indent: A string appended to each menu item title. Increments by '--' per depth level.
$toc: Reference to the table of contents array. This is modified in place, so the function does not have a return value.
$exclude: (optional) An array of menu link ID values. Any link whose menu link ID is in this array will be excluded (along with its children). Defaults to an empty array.
$depth_limit: Any link deeper than this value will be excluded (along with its children).
1 call to _book_toc_recurse()
- book_toc in modules/
book/ book.module - Returns an array of book pages in table of contents order.
File
- modules/
book/ book.module, line 1168 - Allows users to create and organize related content in an outline.
Code
function _book_toc_recurse($tree, $indent, &$toc, $exclude, $depth_limit) {
foreach ($tree as $data) {
if ($data['link']['depth'] > $depth_limit) {
// Don't iterate through any links on this level.
break;
}
if (!in_array($data['link']['mlid'], $exclude)) {
$toc[$data['link']['mlid']] = $indent . ' ' . truncate_utf8($data['link']['title'], 30, TRUE, TRUE);
if ($data['below']) {
_book_toc_recurse($data['below'], $indent . '--', $toc, $exclude, $depth_limit);
}
}
}
}