Is there a way to make the title of a Book navigation block a click-able link to the first page of the book?

I want users who are mid-book to have an easy way to get back to the beginning. I guess people could click on the Breadcrumb, but I have a feeling the top of the navigation block will feel like the "natural" thing to do. (It is for me.)

I've gotta be missing something simple here...

Thanks,
Patricia

Comments

agentrickard’s picture

You aren't missing anything. That's how the code was designed.

I created a custom block to handle this, but the code is behind a firewall until tomorrow when I get back to work.

I'll come back and post it then.

If you know PHP, you can create the block yourself by rewriting http://api.drupal.org/api/5/function/book_block as a custom PHP block.

--
http://ken.blufftontoday.com/
http://new.savannahnow.com/user/2
Search first, ask good questions later.

agentrickard’s picture

Here's the custom block information. Just use this instead of the default book block.

Block description: Custom book block

Block title: leave empty

Block body:

      $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;
        }
      }
      $subject =  l($path[0]->title, 'node/'. $path[0]->nid);
      $content = book_tree($expand[0], 5, $expand);
      print '<h3>'. $subject .'</h3>';
      print $content;

Input format: PHP code

Show block on specific pages: Show if the following PHP code returns TRUE (PHP-mode, experts only).

Pages:

// Only display this block when the user is browsing a book:
    if (arg(0) == 'node' && is_numeric(arg(1))) {
      return TRUE;
    }
    else {
       return FALSE;
    }

--
http://ken.blufftontoday.com/
http://new.savannahnow.com/user/2
Search first, ask good questions later.

PRFB’s picture

That's awesome. Thank you!

Christefano-oldaccount’s picture

My only addition is to help make this custom block support Activemenu. Currently you need the HEAD version of JavaScript Tools and then surround the above print $content; with the original book navigation block's CSS elements:

      print '<div class="block-book" id="block-book-0">';
      print $content;
      print '</div>';