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.
When a crumb plugin like the path one evaluates a View it does not include the overwritten/updated Breadcrumb or create one of it's own it simply considers itself as on the root page of said view. It would be nice if it:
- used any views breadcrumb overrides -or-
- used the title if different from a parent path -or-
- (if I win the willy wonka chocolate factory winning ticket for a feature request) had a token replacement form in the UI telling crumbs how to handle each contextual filter argument for specific a view.
Comments
Comment #1
donquixote CreditAttribution: donquixote commentedI usually write custom site-specific plugins in those cases.
Are you talking about views pages with arguments, or with fixed url?Duh, I should read the issue title :)
Comment #2
donquixote CreditAttribution: donquixote commentedDoes the path of the views page contain an explicit % placeholder?
Comment #3
jpstrikesback CreditAttribution: jpstrikesback commentedYep, it does contain specific placeholders (I.e. blogs/%/%/%) and then various page displays walk upwards/backwards to/from there (blogs/user/year/month)
Comment #4
jpstrikesback CreditAttribution: jpstrikesback commentedAnd yeah,I figured this was a site specific plugin use case...tho if there was a generalized way, that would be amaizyballs
Comment #5
donquixote CreditAttribution: donquixote commentedOk, can you describe / spec out your use case in more detail, so I could reproduce it at home (or in my head), maybe I can do sth about it.
I like amaizyballs.
Comment #6
jpstrikesback CreditAttribution: jpstrikesback commentedAwesome, will do later tonight!
Comment #7
jpstrikesback CreditAttribution: jpstrikesback commentedOK so I have multiple views that use URL arguments to feed contextual filters (And some that use Term ID on Node/Term Page, etc). On these views when a Contextual Filter value is present or a default is provided I send that item to the Override Title & Override Breadcrumb. If we take a view of User Blogs which is available at:
/blogs
but also has a page display that is available at:
/blogs/USER
and:
/blogs/USER/YEAR
and:
/blogs/USER/YEAR/MONTH
for each Contextual filter I override the breadcrumb with a input value from the URL (or wherever I get the contextual filter input from). This works for normal breadcrumbs but only shows the root view (i.e. Blogs from /blogs) as a valid parent when Crumbs evaluates the path. It's probably by design, but the breadcrumbs work when crumb is disabled, and disappear when enabled. I currently use Context to place the crumbs breadcrumbs where I want them (and disable normal breadcrumbs in Omega)
Let me know if that was useful as a usecase or if you want more info.
Comment #8
donquixote CreditAttribution: donquixote commentedOk. So it is all the same display you use for /blogs/USER, /blogs/USER/YEAR etc? Or are these separate displays?
Maybe it helps to have separate displays for each ..
Also it would be interesting what you find in the menu_router table for those views paths. Do you find blogs/% and blogs/%/% and blogs/%/%/%, or only just blogs/% ?
Comment #9
jpstrikesback CreditAttribution: jpstrikesback commentedEach one is a separate display:
/blogs (landing, no argument)
/blogs/user (/blogs/%)
/blogs/user/year (/blogs/%/%)
/blogs/user/year/month (/blogs/%/%/%)
Just checked the menu_router table and each of the display paths are in there (blogs, blogs/%, blogs/%/%, blogs/%/%/%)
Now, just to give some more background on this specific set of views/displays there is more to it which may or may not be pertinent but I'll include it for good measure:
There is an additional view with displays that loads some of the above displays via a No Results Global View Area for some of the displays, maybe this has an impact so I'll list the full monty of displays and inheritance:
blogs
blogs/YEAR ->no results go to blogs/USER
blogs/YEAR/MONTH ->no results go to blogs/USER/YEAR
blogs/USER/YEAR/MONTH
That is a total of 6 displays staggered. Some of them share the same path and the winner is determined by the order of the views & displays...but it works.
Comment #10
donquixote CreditAttribution: donquixote commentedAnd with Crumbs, the breadcrumb you get on blogs/USER/YEAR/MONTH is just blogs/ ?
Can you check in menu_router table what is the title and title callback for those items?
Comment #11
jpstrikesback CreditAttribution: jpstrikesback commentedYup, just "blogs" with crumbs (NOTE: as if it is on the /blogs page, as I have it set to show the current page after the breadcrumb)
Actually the title is only set for the root path to the views (it is set to Blogs), the callback is simply t() for that and all the others. I set the title dynamically via the contextual filter so I have never set the default title for these displays.
Comment #12
donquixote CreditAttribution: donquixote commentedAh, very interesting!
I had a look myself, and indeed Views does not set a title or title callback for those paths.
That's a pity, because if the title is empty, the breadcrumb item will be skipped.
Solution:
We should write a Crumbs plugin with findTitle(), that should determine the correct title for those breadcrumb items.
Could you draft something? I assume you already made a custom plugin, so you are maybe half the way already :)
Comment #13
donquixote CreditAttribution: donquixote commentedOr we could ask over at views if they can do something for us :)
Would be nice if Views would put something more useful into the menu_router table.
Comment #14
jpstrikesback CreditAttribution: jpstrikesback commentedI haven't started one yet, but I will either tmrw or friday, in a perfect world what would views do?
Comment #15
donquixote CreditAttribution: donquixote commentedViews should register a title callback that is based on the title setting.
Or, to not mess around with existing sites, it could provide an additional setting to determine the title callback.
Btw, I tried creating a view with an "author uid" argument, and configured %1 for the dynamic title, but this only sets the uid as the title, instead of the node author name. any idea how to get the node author name instead?
Comment #16
jpstrikesback CreditAttribution: jpstrikesback commentedMm, interesting, would one then pick their favourite source for the title callback or something (in the case of an additional setting)? As far as the author UID I've made a bunch of contextual filters and validators I should probably throw in a sandbox that let me grab a UID from a aliased username out of a path component, then for the title I use first result row substitutions (you can do that, it's just not documented) via the content author relationship. Then when I am spitting the input back into the breadcrumb it uses what it was given via the filter.
Comment #17
jpstrikesback CreditAttribution: jpstrikesback commentedOh, I believe you can also substitute !1 for %1 to get the item title/name
Comment #18
donquixote CreditAttribution: donquixote commented#16
wow, this sounds complex :)
I usually don't use views pages with arguments at all. Instead I use entityaspect + display suite dynamic fields + views content pane. This also allows to put display other fields of the entity (e.g. the user) next to the view.
However, this only works for entity paths so far. Would be interesting to make a more generic "routeaspect", and display suite to have additional fields based on additional wildcard arguments :).
Comment #19
donquixote CreditAttribution: donquixote commentedOn Views queue:
#616922-5: Set title in menu_router table
(This is an old issue, so it could happen that someone decides that a new issue should be opened instead)
Comment #20
jpstrikesback CreditAttribution: jpstrikesback commentedWow, entityaspect looks very, very cool!
Comment #21
donquixote CreditAttribution: donquixote commentedOk, if you want to do something on Crumbs, the first step would be to grep in Views for drupal_set_breadcrumb(), and see how they load the information necessary to build the breadcrumb.
(I suppose they have to load the entire view, which is a bit unfortunate)
Comment #22
pnigro CreditAttribution: pnigro commentedI am experiencing the same problem when a taxonomy term page is overridden by a view at path taxonomy/term/%. The title of the taxonomy term page is empty when _findTitle tries to find it. In the current version of Views, 7.x-3.5, the breadcrumb is set within the function get_breadcrumb in view.inc line 1656. It looks as though the view would have to be loaded. I would love to see this feature added. I am still learning how to code. but I can test.
Thanks
Paul
Comment #23
jpstrikesback CreditAttribution: jpstrikesback commentedOk this may be a big silly question (cause I still haven't dug in, will shortly) couldn't we hijack/piggy back on drupal_get_breadcrumb since views has just loaded it up for us?
Comment #24
donquixote CreditAttribution: donquixote commented#23,
#1794764: Provide a "legacy" plugin
I have some objections to drupal_set_breadcrumb(), because this breadcrumb is not available on child pages.
I am experimenting with a custom Crumbs plugin myself now..
Comment #25
jpstrikesback CreditAttribution: jpstrikesback commentedI think you may need a new handle, something like quickdrawquixote ^^ :) re #1794764: Provide a "legacy" plugin fair points especially hook_init, I just cringe at the thought of loading the view again to get the crumb, tho if everything is cached up the ___ then maybe it's ok?
Comment #26
donquixote CreditAttribution: donquixote commentedI don't really know how the view is cached, I just suppose it is.
I did a quick experiment where it said that it needs around 5-6 millis.
My local codebase is currently a bit messed up, so I don't post a patch. Instead
- Download the crumbs.views.inc.txt, rename it to crumbs.views.inc, and put it into the plugins/ folder of crumbs.
- Modify crumbs_get_plugins() in crumbs.module to add "views" in the list of modules supported by default.
- Clear the cache.
The file contains some benchmark code, I thought you might be interested in that.
Comment #27
donquixote CreditAttribution: donquixote commentedHere is the essential stuff I do with the view:
There might be an easier way to do all this..
The important thing is that we don't execute() or render() the view.
Comment #28
donquixote CreditAttribution: donquixote commentedHmm,
maybe a bad idea to array_pop() and thus modify the view itself.
Might be better to copy the breadcrumb before we pop(), or just say end().
Comment #29
jpstrikesback CreditAttribution: jpstrikesback commentedThis pretty much works. For my use case (all the views embedding) it needs a few extra (painful) additions:
Normal area views (that ship with views) actually don't send a breadcrumb back so I'm using this: Views Area View with More, the whole thing is a bit bad already (executes a cloned view), but now I've found that a view areas rendered title & crumbs don't necessarily get cached with the view it would seem so I'm thinking around that a bit...like maybe imitating all the work views does to prepare it's crumbs...thanks for all of this!!!
Comment #30
donquixote CreditAttribution: donquixote commentedHave you considered using panels?
I don't have much experience with that, but afaik it lets you define the page and arguments independent of the views you put on the page.
Comment #31
donquixote CreditAttribution: donquixote commentedCool stuff:
There are reasons why we don't use drupal_get_breadcrumb() in findParent().
But we can use it in findTitle() !
At the moment that this plugin method fires, the drupal_get_breadcrumb() is already filled. So we could base the views plugin on drupal_get_breadcrumb().
------
Just tried this, and found this:
drupal_get_breadcrumb():
The links and titles are messed up!!
If you click on the piece saying "admin", you would be sent to the main unfiltered view. If you click on "2012" you would be sent to the view filtered by uid, but not to the one filtered by year.
Ouch.
Comment #32
jpstrikesback CreditAttribution: jpstrikesback commentedHa! I was playing around with that and found out the same, but one could do a strip tags and then merge with the item map perhaps?
Comment #33
donquixote CreditAttribution: donquixote commentedI want a safe way to know which title maps to which path. I wanted to use the href for that.
Attached is yet another attempt of a crumbs.views.inc plugin.
Comment #34
donquixote CreditAttribution: donquixote commentedViews queue: #1919456-2: Views breadcrumb: Wrong href for titles
In combination with this patch on views, I get the correct breadcrumbs for my views.
Comment #35
donquixote CreditAttribution: donquixote commented#34: Turns out this is actually not a bug in views but the intended behavior.
---------------------
Completely new approach!
One patch for 7.x-1.x, another for 7.x-2.x
How to use:
- Create a view with the typical News > (year) > (month) > (day)
- (multiple displays with news, news/%, news/%/%, news/%/%/%)
- (no breadcrumb configuration within views needed)
- Set
news/[node:created:custom:Y/m/d]
as entity parent for news.- Apply the patch.
- Visit one of the news.
-> Profit.
Comment #36
donquixote CreditAttribution: donquixote commentedI still have some performance concerns.
But please, test it!
Comment #38
donquixote CreditAttribution: donquixote commentedRemoving brackets around the titles (only had them to prove that the plugin is in effect).
Btw, branch stays on 7.x-1.x, because we start with the older branch and merge upwards.
Comment #40
donquixote CreditAttribution: donquixote commented#38: crumbs-7.x-1.x-views-contextual-filters-1914718-37.patch queued for re-testing.
Comment #41
donquixote CreditAttribution: donquixote commented#35: crumbs-7.x-1.x-views-contextual-filters-1914718-35.patch queued for re-testing.
Comment #42
donquixote CreditAttribution: donquixote commentedQueuing up the 7.x-2.x patches
Comment #43
donquixote CreditAttribution: donquixote commented#35: crumbs-7.x-2.x-views-contextual-filters-1914718-35.patch queued for re-testing.
Comment #44
donquixote CreditAttribution: donquixote commented#38: crumbs-7.x-2.x-views-contextual-filters-1914718-37.patch queued for re-testing.
Comment #45
jpstrikesback CreditAttribution: jpstrikesback commentedFlipping fantastic!! Way better performance than I had running (I was building my views and then executing embedded views)!
Here is a version that takes care of embedded views and null arguments.
Check out the TODO and tell me if you can see anything wrong here, I've tested this on the rather complex setup detailed in #9 above and all works well.
Cheers!
Comment #47
jpstrikesback CreditAttribution: jpstrikesback commentedwrong version
Comment #48
jpstrikesback CreditAttribution: jpstrikesback commented#45: crumbs-7.x-1.x-views-contextual-filters-1914718-45.patch queued for re-testing.
Comment #49
donquixote CreditAttribution: donquixote commentedAm I correct in assuming that this is rather an edge case, which only applies with your sandbox?
If not, please enlighten me :)
I would suggest to keep the main views plugin simple (only support page views).
Then there can be an additional plugin for embedded views. Might even be part of your sandbox instead of Crumbs.
And keep in mind, there is still the option of site-specific Crumbs plugins.
The implementation I suggested does not even care about the breadcrumb config of the view. It always gets the title from the last argument, no matter how that is configured. If you are not happy with that, you need to disable the plugin for this specific views display, and/or override it with your own.
Have not really thought about this. +1.
Comment #50
donquixote CreditAttribution: donquixote commentedThis has a benefit:
With the usual Views breadcrumb, you never get the last item.
If you have the typical news/%/%/% with
News > (year) > (month) > (day), what you would do in views config is this:
first argument (year): breadcrumb name: NOTHING
second argument (month): breadcrumb name: %1 (year)
third argument (day): breadcrumb name: %2 (month)
So if you visit a day display, you get a breadcrumb of
News > (year) > (month) >
so the day is not part of the breadcrumb (only of the page title)
If you visit a news node, and want the breadcrumb to be provided by the view, respecting the views config, then you can never have the day as part of the breadcrumb.
Same if you want to always show the current page in the breadcrumb.
Besides, the behavior I suggested seems like a very solid default.
I consider it more likely that people mess up (or simply don't care about) the views breadcrumb config, than people wanting a non-default behavior.
Comment #51
donquixote CreditAttribution: donquixote commented#9
just wondering.. is this a good design?
What I can imagine as reasonable behavior is this:
The idea being that the user intended to see the blog posts from June 2013.
If we show something else instead, we need to give an explanation.
And for the breadcrumb: Imo better to let it indicate that "yes, this is the place you were looking for. We are out of order atm, but you can stop searching". So, even if you show something else in the "no results", that should not affect the breadcrumb. Because if it does, it can feel to the user like she has mis-clicked.
If you still want the breadcrumb to be modified based on the embedded view, I am sure this can be done with a custom site-specific plugin.
Comment #52
jpstrikesback CreditAttribution: jpstrikesback commentedHeh heh, lots to reply to :) here goes:
It is an edge case, as are embedded views that pass anything back. That said, if embedded items are checked then my sandbox isn't actually required for setting the breadcrumb. I.E. crumbs provides that (with the patch I added above). Tho I'm all for this being site specific / custom plugin.
I love this, it's perfect IMO other than not handling null arguments.
The idea is that I needed to be able to validate an argument at (eg.) position 2 that is either a DATE or a USER and allow the first one that passed validation to render/modify the query. Definitely an edge case, and pushing views in places it doesn't exactly want to be perhaps. Changing the design to USER/blog could possibly work for the usecase (not sure off hand).
Comment #53
donquixote CreditAttribution: donquixote commentededge edge edge.
Ok can you help with the "null arguments" ?
Comment #54
jpstrikesback CreditAttribution: jpstrikesback commentedSure, on a scale from ugly to works where we at with how I did it up there?
Roughly:
Comment #55
donquixote CreditAttribution: donquixote commentedI don't really know, the #45 had a lot of stuff for the embedded views which I was not so motivated to study.
(esp. because I am traveling and rather wanted to see Pompei :) )
I was hoping for a stripped-down version, consisting of #38 with added null handling, and an interdiff to #38 (don't care which branch)
But, let me have a look at the snippet in #54.
I wonder if we need that. Can you explain a bit about the use case?
E.g. in the example I gave we have these views displays:
news/%/%/% -> news for a given day
news/%/% -> news for a given month
news/% -> news for a given year
news -> all news
In the breadcrumb we work our way through all the displays, and only ever look at the last argument.
But, what if we only had the day thing and the "all news"?
news/%/%/%
news
Which breadcrumb would be intended?
Comment #56
jpstrikesback CreditAttribution: jpstrikesback commentedMy thinking on grabbing the previous argument handlers title is that if a null handler is being using and it doesn't provide a title it is being used to ignore some contextual value, and since we only care at this point in evaluation for the last argument we should at this point move back one and ignore the null argument...
IMO this is a view design problem :) At least if the designer wants sane breadcrumbs with crumbs :) ...Do we somehow construct a fallback that extracts the full breadcrumb as given from $view->build_info['breadcrumb']?
Comment #57
donquixote CreditAttribution: donquixote commentedCan you give an example situation for a null argument?
As in: Views config, argument values, and intended breadcrumb.
Comment #58
bojanz CreditAttribution: bojanz commentedPatch in #38 solves my use case perfectly.
Attaching version that applies against 1.9, so that I can add it to Kickstart (we could use a new 7.x-1.x release, btw).
Comment #59
donquixote CreditAttribution: donquixote commentedI wonder if we can further speed it up with caching.
I think it would be justified to do this as a one-off only for this plugin, because views tend to be more expensive to load than terms, nodes or users. (the debug page will tell you)
Comment #60
donquixote CreditAttribution: donquixote commentedIt is a shame that views argument handlers can only be used in combination with the view, and not standalone.
Comment #61
donquixote CreditAttribution: donquixote commentedPushed to 7.x-2.x.
Comment #62
lmeurs CreditAttribution: lmeurs commented@donquixote: When you say "Pushed to 7.x-2.x.", do you mean the fix is available in the latest dev release?
The problem still occurs with 7.x-2.0-beta1+0-dev, downgrading to 7.x-1.10+0-dev solved the issue for me.
I used simplytest.me with just Views and Crumbs installed. I enabled the
taxonomy/term/%
view, cleared the cache, created an article with a tag, visited the tag's term page and got the following error:Thanks for the great work!
Comment #63
donquixote CreditAttribution: donquixote commentedWhat is "+0-dev" ?
Going to try myself now.
Comment #64
jpstrikesback CreditAttribution: jpstrikesback commentedJust FYI I just upgraded to 7.x-2.x-dev and without a little cache clear I received a rather awesome:
"method_exists(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "crumbs_CrumbsMultiPlugin_NodeParent" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition" in sites/all/modules/crumbs/lib/PluginInfo.php:170
After a cache clear all was well again.
Comment #65
donquixote CreditAttribution: donquixote commented@jpstrikesback: Ok, I think I know why.
I recently killed the class crumbs_CrumbsMultiPlugin_NodeParent. But git checkout does not trigger a cache clear.
On the other hand, regular module update does trigger a cache clear. So I guess this is something we can live with.
Comment #66
donquixote CreditAttribution: donquixote commented@lmeurs: Could I have a stack trace?
Can you enable devel on simplytest.me and tell it to show a stack trace?
Comment #67
jpstrikesback CreditAttribution: jpstrikesback commentedAh interesting, I did it via drush, but yeah, can totally live with it...
Also, all of my taxonomyesque view pages are working (tho I've turned off the normal displays with Taxonomy Display module and use views magik™)
Comment #68
donquixote CreditAttribution: donquixote commentedHm.. maybe it only flushes if there is actually a hook_update_N() going on?
Maybe I will add an emtpy hook_update_N() in the next beta.
Comment #69
lmeurs CreditAttribution: lmeurs commented@donquixote: Sorry for the late reply, I was gone on vacation. :-)
The "+0-dev" version number suffix was added by the drupal.org packaging script to the version number inside the .info file.
With the beta7 version I cannot reproduce the error anymore, great! Later on I will try this latest release on the development project.
Thanks again!
Comment #70
lmeurs CreditAttribution: lmeurs commented@donquixote: Installed and quickly tested 7.x-2.0-beta9, so far so good!
Comment #71
donquixote CreditAttribution: donquixote commentedThere seems to be a problem with htmlentities in the title provided by the views plugin.
#2074549: Taxonomy titles with & displaying as html entity &
Views already runs htmlentities, then Crumbs does it again.
Can someone have a look at the other issue and confirm the problem and solution?
Having a 3rd pair of eyes is always useful!
Thanks!
Comment #73
donquixote CreditAttribution: donquixote commentedHey everyone..
As this has been one of the more frequented issues, I would like to take the chance for a bit of "advertising", for everyone who is going to attend DrupalCon.
#2094933: Crumbs BoF/meeting on DrupalCon Prague 2013?
The format and time is not decided yet, and will depend on the feedback I get. For my own taste, it could be some time during the code sprints, or in the evenings - so none of us will miss any sessions.
(and no worries, I am not going to spam every issue with this, only a few)
Comment #73.0
donquixote CreditAttribution: donquixote commentedUpdated issue summary.