Hi,

I need help with setting up custom breadcrumbs for book pages. Structure is the following:

term
book (first level)
book page (second level)
book page (third level)
book page (fourth level)

When I view the first level I get:

Home - term - book

That's great, I need it like that. But, when I visit e.g. 4th level book page I get:

Home - term - book page (fourth level). I could eventually get Home - term - book (1st level) - book page (fourth level).

I want to see every parent node in the breadcrumb. That would look like this:

Home - term - book - book page (2nd level) - book page (3rd level) - book page (4th level)

I read this issue: http://drupal.org/node/521324 but haven't managed to set it up correctly. I'm using pathauto and paths for book pages are:

example.com/term/book/2nd-level-book-page/3rd-level-book-page/4th-level-book-page

First of all - which type should I choose - node or path?

Thank you in advance!

Comments

MGN’s picture

You would want a node-type breadcrumb with node-type book page, but the problem is that there isn't a token (to my knowledge) that provides a separate crumb for each parent. The closest is [bookpath-raw] which would provide a breadcrumb like

term >> book (first level)/book page (second level)/book page (third level)/book page (fourth level)

with 'term' linked to /path/to/term/page and the book path linked to book page (third level).

To set up this breadcrumb you would use:

Titles

term
[bookpath-raw]

Paths

path/to/term/page
<pathauto> | [bookpath-raw]

If you really want every parent to show with separate links in the breadcrumb, you would need to write some custom php code to create each part of the crumb and use the advanced option to use php code in defining titles and paths.

lion123’s picture

Thank you for your answer. Yes, I have already tried that one and it's not suitable to my needs.

Well, I'm not that good at php. I have found the token for book url (http://drupal.org/node/403266). It's in the form of a patch. Since I'd like to avoid patching, is there a way to use that code in these custom php fields in custom breadcrumbs?

MGN’s picture

I don't think that code will accomplish your goal either. Tokens only return a single value. In your example it seems like you need about 4 separate values, the title linked to the path for each level?

There is a feature request to use identifiers to generate multiple crumbs in cases like these. See #754494: Provide hooks for modules to provide special identifiers for custom breadcrumbs, capable of building multiple crumbs for details. When that is implemented, this might become much easier.

lion123’s picture

Aha, I see. Thank you for the notice.

Well, then I hope it will be implemented soon :)

MGN’s picture

Version: 6.x-2.0-beta2 » 6.x-2.x-dev
Category: support » feature
Status: Active » Fixed

#754494: Provide hooks for modules to provide special identifiers for custom breadcrumbs, capable of building multiple crumbs has now been committed to 6.x-2.x-dev. With the new custom breadcrumbs identifiers sub module enabled, you'll see a new <book-hierarchy> identifier that provides multiple crumbs, one for each parent node in the book hierarchy. Just place that in the titles and paths section of the custom breadcrumb. So I think this feature request has been fixed.

lion123’s picture

I have tried this feature in beta3 version and it works great. Thank you for implementing it!

lion123’s picture

Status: Fixed » Active

Hi,

I have noticed a small bug. I'm using the following setting for my book pages:

It produces double crumb in trail for the top book page. If I have a book called Drupal with children Modules and Themes, the Drupal page has the following breadrumb:

Home - Drupal - Drupal

But when I navigate to Modules page, I get:

Home - Drupal - Modules

MGN’s picture

Status: Active » Postponed (maintainer needs more info)

Your setting didn't come through, can you try enclosing it in code tags so I can better understand the issue?

Thanks.

lion123’s picture

I don't know why, but I didn't notice your reply, sorry.

Here is my data:

vocabulary: Drupal
book (top book-page): Modules
book (child book-page): Article

When I open Modules page, I get the following breadcrumb:

Home » Drupal » Modules » Modules

When I open "Article" page, everything is ok and I get the following breadcrumb:

Home » Drupal » Modules » Article

My settings for the book pages:

<book-hierarchy>
<page-title>
MGN’s picture

Status: Postponed (maintainer needs more info) » Fixed

Thanks. This has now been fixed in 6.x-2.x-dev. http://drupal.org/cvs?commit=375612

Status: Fixed » Closed (fixed)

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