This is a patch to include the top-level book page in the book navigation block. I think this makes the navigation block a lot more useful. Before this patch, all pages in the book were included in the block except for the root level page, so it was difficult to get back to the root level.

I don't know if this is the best way to do it, but it works and affects only book_tree() and book_block().

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ezheidtmann’s picture

FileSize
1.38 KB

Sorry... Here's the patch.

puregin’s picture

clydefrog, your patch breaks the default behaviour of book.module,
which is to allow multiple independent books.

In other words, there is - by design - no unique 'top-level book page'.

You probably want to create a book page to be a parent for all of your
existing pages; this will let you navigate via the book module block as
you desire.

bomarmonk’s picture

Can't you still have multiple, independent books and still show the root page in the navigation block for these independent books? Why not have this flexibility? I only know that if you are using the book navigation for departmental information (for example) and you make the first page of the department "board" (for example) the initial index and information page will not display unless I use this patch. Why would I want it to behave otherwise? What would I use this root page to display? Where? Perhaps I am not understanding why I would want this root page to be invisible in my navigation block, since it would be a starting point for all other pages in that book? But then again, I'm looking at the book module for possibly creating a hierarchal structure for my entire website, and the navigation blocks for books as a way to create structured navigation to this content. Since taxonomy does a poor job of presenting the browser with structured, static content, this may be my only other option.... I'll keep trying to understand all of the uses for these modules, but in the end I need them to work for me and my purposes... of course Drupal is supposed to have flexibility in this regard, but I'm finding that navigation and menus for hierarchal, static conent isn't one of Drupal's strong points. Maybe a seperate module needs to find its way into the core that accomodates such purposes? I'm not sure: again, I'm still learning, but this is becoming a rather difficult issue to "navigate" (no pun intended- yeah right).

ezheidtmann’s picture

Re: puregin in #2

My patch still allows multiple independent books. When I speak of the 'top-level book page', I speak of the root page of an individual book.

ezheidtmann’s picture

Version: 4.6.0 »
FileSize
1.43 KB

Here's an updated patch for HEAD. The earlier patch was against a modified 4.6, so probably wouldn't have worked anyway.

bomarmonk’s picture

Should this patch work in conjunction with the other patch here: http://drupal.org/node/1412?

This other patch allows book blocks to appear on all pages as menus for a site (not just menus for when you are already inside the book).

Also, another thought on your patch: why not make the title of the book itself be the link to the root page in the book navigation block? This would make the menu block more efficient and it would seem to be a logically sound modification-- no matter how these blocks are used.

Thanks again for your contribution to the book module-- I believe it will prove quite valuable to those who want to use books to organize and create menus for a hierarchal website.

ezheidtmann’s picture

bomarmonk, I answered your question in the forum. Please don't double post.

puregin’s picture

Sorry for missing the point of your patch in my previous posting, clydefrog. Now that I'm clued in, I agree that it's useful to have the parent listed in the hierarchy. I'm not in a position to install the patch yet, so I can't comment on how well it works. One possible quibble - this would add an additional level of indentation, which might cause excessive rightward drift and 'squashing' of titles in the display block. Also, though it's not completely consistent or intuitive, the parent title is presented as the book navigation block title, so it's not completely 'missing'.

ezheidtmann’s picture

FileSize
1.56 KB

It is true that this adds another level of indentation, but I don't think it's enough to worry about. If things get crowded on your site, you can modify your theme and you should probably consider rearranging your book's organization. The parent's title is shown in the title bar of the block, but it's not a link so it doesn't help with navigation. I considered making it a link, but that would be inconsistent: no other block has a link in the title.

The updated patch syncs with HEAD. It was generated with cvs diff -u; hope that's all right.

Does anyone else have an opinion on this patch? Please give me some feedback! Thanks.

puregin’s picture

I'm OK with the extra level of indentation. (Just one more good reason not to let book hierarchies get too deep!)

Djun

ezheidtmann’s picture

Sorry, the last patch was broken.

Dries’s picture

The fact the block's title is repeated looks a bit awkward. At the same time, I see why this change would be helpful.

What if you have multiple books? For the other links in the book navigation block, all parents are shown so when multiple books are available, the parent-link's behavior would be somewhat inconsistent. This isn't a problem per se given the parent is special anyway.

PS: have you seen http://drupal.org/node/14120?

drewish’s picture

I haven't tried out this patch yet (I'm sort of expecting that I'll take some work to get it to apply to HEAD) but I'm all for the change. The current behavior is a real pain in the butt.

chx’s picture

Status: Needs review » Needs work

Patch does not apply

markdionne’s picture

Version: » 4.7.6

I have a simpler fix. Just change one line in function book_block:
// $block['subject'] = check_plain($path[0]->title);
$block['subject'] = l(check_plain($path[0]->title), 'node/'. $path[0]->nid);

Seems to work fine in 4.7.6

druvision’s picture

Version: 4.7.6 » 6.0

#15 Works great in 5.0.

This should really be a core feature of 6.0 - is it?
Clicking on the title of the book block should bring us to the top book page.

Damien Tournoud’s picture

Version: 6.0 » 7.x-dev

Feature requests have to go to the development version (7.x) first.

I also think the best way to do this would be to make a link in the block title. But is this supported?

GuillaumeDuveau’s picture

#15 works OK in 5.10 but it's a hack of core ! Unfortunately book_block is not a themable function in 5.x so I guess it can't be done without any hack because it can't be overriden. I hope in 7.x the link on the root of a book can be implemented in the book navigation block or at least that the block can be themed.

GuillaumeDuveau’s picture

Status: Needs work » Fixed

The feature seems to be now integrated in Drupal 6.6 core so I'm setting the issue status to "fixed".

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

mathias00’s picture

I have Drupal 6.8 and did not find it. Can you provide some insight ?

Thanks

mathias00’s picture

Status: Closed (fixed) » Postponed (maintainer needs more info)
mathias00’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

Default block title includes link.