As soon as I set a custom breadcrumb for a specific path, I loose the page title in the browser bar. The title should be '[page-title] : [site-name]' however, All I get is ': [site-name]'. If I delete the custom breadcrumb, I get the title back to normal.
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | 454356_cb_paths_fix_views_2.diff | 7.41 KB | mrfelton |
| #9 | 454356_cb_paths_fix_views.diff | 7.23 KB | MGN |
Comments
Comment #1
mrfelton commentedtypo in title
Comment #2
mrfelton commentedI should also note that I am also using the page_title module to control the page titles. I have it set to '[page-title] : [site-name]'. This works everywhere, except where a specify path breadcrumb has been set.
Comment #3
mrfelton commentedI should also note that the page that I am trying to use custom_breadcrums_path for is generated by a View, and the title of that View is set dynamically base on one of its arguments, by using the following code in the PHP argument handling section of the View:
now, commenting out
custom_breadcrumbs_set_breadcrumb($breadcrumb)incustom_breadcrumbs_views_pre_view()in custom_breadcrums_path.module stops the title being deleted - but also stops the breadcrumb being set (obviously!)..And while I'm at it... why is
custom_breadcrumbs_views_pre_view</code in custom_breadcrums_path.module? That doesn't seem right... surely it should be <code>custom_breadcrumbs_path_views_pre_viewif anything?Comment #4
mrfelton commentedand a little further digging shows that commenting out the following lines in custom_breadcrumbs_set_breadcrumb() fixes.
Clearly this is the wrong thing to do as it will break token support - but thats where the problem is
Comment #5
MGN commentedYou are correct that
custom_breadcrumbs_views_pre_viewin custom_breadcrumbs_paths.module should becustom_breadcrumbs_paths_views_pre_view.I would start by changing that (I'll also commit a fix for the nightly snapshot).
I am not familiar with the page_title module. Can you tell me if [page-title] is a token, and if so, what is its scope (node or global or ...)?
Also, is the view embedded in a node?
EDIT: Additional questions:
Does the same thing happen when you use node_type custom breadcrumbs? custom_breadcrumbs_views breadcrumbs? or does this only happen with path breadcrumbs?
Comment #6
mrfelton commentedIt only seems to happen with path breadcrumbs. [page-title] is indeed a token, provided by the page_title module. It is a global scope token:
I think that what is happening is related to token caching - if I stop the token module from caching it's results (by hacking the code), then the problem goes away and I get both a custom breadcrumb, and the correct page title. Perhaps custom_breadcrumb, or page_title is passing token an incomplete object in $type, that is, an object which has a blank value for ->title? I initially thought that it may be because you are running this at such a point in the views hooks, that the custom argument handling code hasn't run yet, and therefore my title hasn't been set - but I tried altering it to use other views hooks and id made no difference. I also tried setting a static title on my view, just to rule out the views argument handing as the source of the problem, and still, no change. See http://drupal.org/node/213548#comment-822926 for info on a similar problem.
Comment #7
MGN commentedIn reading through the page_title module code in cvs, It seems that page_title doesn't support views pages. There is an issue (in progress) to do this at #176985: Support For Views. Of course if your view is embedded in a node then this might not matter.
The fact that one global scope token is working [site-name] indicates that the problem must have to do with the way that [page-title] is being created.
At this point I don't think this is a problem with custom_breadcrumbs_paths, but I'll change my mind if the same problem occurs with other (global) tokens.
Comment #8
mrfelton commentedThere is indeed no support in page_titles for overriding the page title for Views pages. However, [page-title] will default to the value returned from drupal_get_title() if there is no overriden page title (from the modules hook_help, below) - this goes for views pages too. The lack of views support (as I understand it) is simply about being able to override the default page title per view...
So that doesn't explain why the [page-title] token works for all cases (Including for Views pages, where the [page-title] is set to the value of drupal_get_title()), except when a path custom_breadcrumb is set.
It also doesn't explain how forcing token.module to NOT cache its results results in both the breadcrumb AND the page title being set correctly. This seems like an indication of the cause... that either custom_breadcrumbs or page_title is doing something wrong, and a blank value for [page-title] is being set somewhere along the way, and cached.
For reference, this is from the modules hook_help
Comment #9
MGN commentedThanks for the clarification. I ran across another bug in the custom_breadcrumbs_paths code that may or may not relate to this issue.
I noticed that when a page had block views displayed with a node, cb_paths_nodeapi and cb_paths_views_pre_view were both setting the breadcrumb. The custom breadcrumb was written with node-scope tokens, and these were not being replaced because the views code was executed after nodeapi.
This patch modifies the hook_views_pre_view to check to first check if the view has a display with a path that matches the current path before trying to set the breadcrumb.
Its a long shot, but I thought this might be related to the [page-title] token issue.
I don't like mixing issues, but I was actually in the middle of another feature request when I found the problem. So, free of charge, the patch also adds wildcard matching to cb_paths. If desired, this feature can be activated at the custom breadcrumbs settings page (admin/settings/custom-breadcrumbs).
Sorry to combine these issues, but would appreciate it if you would be willing to test the patch and let me know if helps...
Comment #10
mrfelton commentedWhen I read your post:
I thought that really sounded promising. But, unfortunately this didn't fix the problem...
I thought that the issue may be related to something else, sine the site I was having the trouble on has over 120 modules installed! However, I was able to easily reproduce this in a sandbox, and I now have some more info that may help. I have been able to further isolate the problem - it's only an issue if the Specific Path that I am trying to set a cb for is an alias of a view... you should be able to reproduce this:
1) enable page_titles, custom_breadcrumb
2) create a view with page display at /somepath and the the view a title
4) create a path cb for /somepath
3) visit /somepath and confirm that the title in your browser bar is as per you page_titles settings (that [page-title] is resolving to the title of the view) and that your breadcrumb has been applied
3) create an alias to this view at /somepath-alias
4) create a path cb for /somepath-alias
5) visit /somepath-alias and notice that the breadcrumb still works, but [page-title] is now being replaced with an empty string.
Comment #11
mrfelton commentedComment #12
mrfelton commentedActually, I take that back - it doesn't work for the View weather its accessed directly or via an alias.
Comment #13
MGN commentedThanks for the great directions. I can reproduce the problem now and should be able to figure this out. Stay tuned....
Comment #14
MGN commentedComment #15
mrfelton commentedRight, think I cracked it:
this patch is exactly the same as your last one, with 2 small alterations...
1) use hook_views_pre_render() instead of hook_views_pre_view() - this seems to stop the token breakage. I think the problem was that at hook_views_pre_view(), a lot of stuff about the view (including it's title) hasn't been set yet... by the time it gets to hook_views_pre_render() all the information is there.
2) use drupal_get_normal_path() in custom_breadcrumbs_paths_views_pre_render() to get the system path - this allows the views path checking to work with aliases, allowing breadcrumbs to be set for views that are accessed at their system path as well as at an alias of that location.
Comment #16
MGN commentedGreat. I agree with both changes and can confirm that [page-title] now works as expected. Thanks for hunting that down. I'll commit the changes.
Comment #17
mrfelton commentedI'm now wondering if we should actually be using drupal_get_normal_path instead of drupal_get_path_alias...?
Comment #18
mrfelton commentedActually... thanking about this again, we should really just use
drupal_get_destination()- since we are interested in applying the cb based on the path the user enters, regardless of weather that is a system path or an alias (i think).Comment #19
mrfelton commentedOK... scratch that. The problem I'm encountering is not actually to do with the way of looking up the alias. It's todo with this code in hook_views_pre_render()
It doesn't allow you to work with views with arguments. For example, a view could be accessed at /someview or /someview/arg1 or /someview/arg2 - all of which are different paths, and I need the ability to set the breadcrumb based on the path to the view, including its arguments. So /someview may have a different breadcrumb to /someview/arg2. However,
$display->display_options['path']only ever contains the base path of the view, so it is impossible to set a breadcrumb for /someview/arg2Comment #20
mrfelton commentedI managed to fix this by altering the check like so:
However, since you have committed this already, I'm going to open a new ticket for this issue.
ps. thanks for your work on this.
Comment #21
mrfelton commented