function _spaces_core_book_tree in Spaces 5
Same name and namespace in other branches
- 5.2 spaces_core/spaces_core.module \_spaces_core_book_tree()
Group-aware book tree generation
1 call to _spaces_core_book_tree()
- _spaces_core_block_book in spaces_core/
spaces_core.module - Spaces version of the book nav block -- shows all root books in a group
File
- spaces_core/
spaces_core.module, line 343
Code
function _spaces_core_book_tree($parent = 0, $depth = 3, $unfold = array(), $gid = NULL) {
if (!$gid) {
$gid = spaces_gid();
}
if ($gid) {
$result = db_query(db_rewrite_sql('SELECT n.nid, n.title, b.parent, b.weight FROM {node} n INNER JOIN {book} b ON n.vid = b.vid JOIN {og_ancestry} og ON og.nid = b.nid WHERE n.status = 1 AND og.group_nid = %d ORDER BY b.weight, n.title'), $gid);
while ($node = db_fetch_object($result)) {
$list = isset($children[$node->parent]) ? $children[$node->parent] : array();
$list[] = $node;
$children[$node->parent] = $list;
}
if ($tree = book_tree_recurse($parent, $depth, $children, $unfold)) {
return '<ul class="menu">' . $tree . '</ul>';
}
}
else {
return '';
}
}