Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I configured some views with contextual filters ("arguments"), and here is the breadcrumb I got:
drupal_get_breadcrumb():
(Array, 3 elements)
0 (String, 22 characters) <a href="/en">Home</a>
1 (String, 36 characters) <a href="/en/news/all/all">admin</a>
2 (String, 33 characters) <a href="/en/news/1/all">2012</a>
The mapping of link path vs link title is broken:
The second url should rather be "/en/news/1" => "admin"
The third url should rather be "/en/news/1/2012" => 2012.
Comment | File | Size | Author |
---|---|---|---|
#2 | views-7.x-3.x-breadcrumb-paths-1919456-2.patch | 924 bytes | donquixote |
Comments
Comment #1
donquixote CreditAttribution: donquixote commentedLooking into includes/view.inc,
view::_build_arguments()
:http://drupalcode.org/project/views.git/blame/refs/heads/7.x-3.x:/includ...
The
$breadcrumb_args[] = $arg;
comes too late. When the url is built, it cannot consider all the arguments that it should consider.Comment #2
donquixote CreditAttribution: donquixote commentedProposed fix.
Btw, I wonder why noone else has reported this yet? Seems like quite a basic misbehavior.. Or did I do something wrong?
Comment #3
donquixote CreditAttribution: donquixote commentedBtw, here is where I come from: #1914718-31: Crumbs on Views with Arguments/Contextual Filters
Comment #4
donquixote CreditAttribution: donquixote commentedA test case would be nice..
Comment #5
dawehnerYou know people are so used to the fact that breadcrumbs are problematic in drupal. Maybe this will change one day with the crumbs module :)
Maybe we should set a small documentation so we never do the same mistake again?
Comment #6
donquixote CreditAttribution: donquixote commentedThe "will" and "one day" indicate that you have not tried it yet :)
Since I made this module, I never had any problem with breadcrumbs that I couldn't solve.
Ideally, Views would set a title callback in hook_menu(_alter). (Ideally, this title callback would not need to load and process the entire view, but just the argument info..) Then Crumbs wouldn't need to do anything extra.
But since this is probably not so easy, we are going to make a plugin for views, which should look into drupal_get_breadcrumb() (which it normally ignores), and extract the titles from there. So we just need the title/href of breadcrumb elements fixed :)
Hm, I am confused, what do you want to document?
Comment #7
donquixote CreditAttribution: donquixote commentedDoes this have a future? rtbc?
Seems quite straightforward to me..
Comment #8
donquixote CreditAttribution: donquixote commentedRelated: #616922: Set title in menu_router table
Comment #9
dawehnerCan't we add some documentation?
Comment #10
donquixote CreditAttribution: donquixote commentedMaybe I see it wrong, but for me this is a bug, not a documentation issue.
Commit the patch, and we are done.
*Unless* this patch has some unpleasant side effects.
What additional documentation do we need?
Comment #11
donquixote CreditAttribution: donquixote commentedOk, I think it is good this was not committed yet.
There is one aspect I missed.
E.g. you have the typical News > (year) > (month) > (day)
You configure the "day" display, the one with 3 contextual filters.
You configure the "day" argument of that display.
For "title" you would put "%3" (but probably you just don't).
But for "breadcrumb name" you put %2, to specify the title of the parent breadcrumb item.
This is because by default, Drupal breadcrumbs never show the current page, they only show from Home to the parent page of the current page.
Read this way, the existing breadcrumb logic is correct. So this is not a bug.
If we would change it, it might harm thousands of websites.
Comment #12
donquixote CreditAttribution: donquixote commentedI mark this as "works as designed".
This being said:
- The behavior could be better documented / labeled.
- For Crumbs, it means we can not use the breadcrumb that was put in drupal_set_breadcrumb(). Instead, we need some creative head-scratching to find a suitable solution. This will become interesting.
Ideally, I want something like this:
If this works, we will get very nice breadcrumbs, easily expanding to listed entities, such as
Home > News > (year) > (month) > (day) > (node title)
with only minimal configuration
I am only a bit worried about performance, if we load the view.
Comment #13
donquixote CreditAttribution: donquixote commentedOk, seems to work!
#1914718-35: Crumbs on Views with Arguments/Contextual Filters