Перейти к основному содержанию

Реклама

Избранное

<?php
function book_tree_recurse_all($nid, $depth, $children) {
if ($depth > 0) {
if ($children[$nid]) {
foreach ($children[$nid] as $foo => $node) {
if ($tree = book_tree_recurse_all($node->nid, $depth - 0, $children)) {
$output .= '

  • ';
    $output .= l($node->title, 'node/'. $node->nid);
    $output .= '
      '. $tree .'

    ';
    $output .= '

  • ';
    } else {
    $output .= '

  • '. l($node->title, 'node/'. $node->nid) .'
  • ';
    }
    }
    }
    }
    return $output;
    }

    function book_tree_expanded($parent = 0, $depth = 3) {
    $result = db_query(db_rewrite_sql('SELECT n.nid, n.title, b.parent, b.weight FROM {node} n INNER JOIN {book} b ON n.nid = b.nid AND n.vid = b.vid WHERE n.status = 1 AND n.moderate = 0 ORDER BY b.weight, n.title'));

    while ($node = db_fetch_object($result)) {
    $list = $children[$node->parent] ? $children[$node->parent] : array();
    array_push($list, $node);
    $children[$node->parent] = $list;
    }

    if ($tree = book_tree_recurse_all($parent, $depth, $children)) {
    return '

      '. $tree .'

    ';
    }
    }
    print book_tree_expanded(0);
    ?>