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
Comment #1
MGN commentedYou 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
Paths
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.
Comment #2
lion123 commentedThank 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?
Comment #3
MGN commentedI 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.
Comment #4
lion123 commentedAha, I see. Thank you for the notice.
Well, then I hope it will be implemented soon :)
Comment #5
MGN commented#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.Comment #6
lion123 commentedI have tried this feature in beta3 version and it works great. Thank you for implementing it!
Comment #7
lion123 commentedHi,
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
Comment #8
MGN commentedYour setting didn't come through, can you try enclosing it in code tags so I can better understand the issue?
Thanks.
Comment #9
lion123 commentedI 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 » ModulesWhen I open "Article" page, everything is ok and I get the following breadcrumb:
Home » Drupal » Modules » ArticleMy settings for the book pages:
Comment #10
MGN commentedThanks. This has now been fixed in 6.x-2.x-dev. http://drupal.org/cvs?commit=375612