You are here

function _spaces_core_block_book in Spaces 5

Same name and namespace in other branches
  1. 5.2 spaces_core/spaces_core.module \_spaces_core_block_book()
  2. 6 spaces_core/spaces_core.module \_spaces_core_block_book()

Spaces version of the book nav block -- shows all root books in a group

1 call to _spaces_core_block_book()
spaces_core_block in spaces_core/spaces_core.module
Implementation of hook_block()

File

spaces_core/spaces_core.module, line 319

Code

function _spaces_core_block_book() {

  // Only display this block when the user is browsing a book:
  $result = db_query(db_rewrite_sql('SELECT n.nid, n.title, b.parent FROM {node} n INNER JOIN {book} b ON n.vid = b.vid WHERE n.nid = %d'), arg(1));
  if (db_num_rows($result) > 0) {
    $node = db_fetch_object($result);
    $path = book_location($node);
    $path[] = $node;
    $expand = array();
    foreach ($path as $key => $node) {
      $expand[] = $node->nid;
    }
    $label = spaces_custom_menu('label', 'documents');
    $block['subject'] = $label ? $label : t('Documents');
    $block['content'] = _spaces_core_book_tree(0, 5, $expand);
    return $block;
  }
}