I have content under the "projects" heading that is then accessed via two menus. For example if I select "informatics" in the first menu and then "Clinical Coding" in the second (and each menu has multiple children but only two levels in total). My path is /projects/informatics/clinical-coding
and my breadcrumb shows as:
Home » projects » Informatics/Clinical Coding
Ideally the breadcrumb should show as:
Home » projects » Informatics » Clinical Coding
with Informatics pointing at /projects/informatics
is this possible?
Apologies if I've missed the answer to this already in my searches... and thanks in advance for any help...
Comments
Comment #1
MGN commentedIf I understand your menu hierarchy correctly, I think this can be done with 'Use Menu Structure' option at admin/settings/custom-breadcrumbs. Enable this option, then select the menu that you want this to apply to.
Note that there is a patch that affects this option at #627792: Custom Breadcrumb option causes Access Denied in OG Forums. If you are comfortable testing code, I would recommend working from the 6.x-2.x-dev version, and apply that patch. I would appreciate the feedback so we can move forward to beta3.
Comment #2
paul.dambra commentedHi,
I upgraded to the latest dev version and tried that setting (which like an idiot I had completely blanked).
I'm not getting any access denied errors but I don't have OG forum or subsites.
I get the correct behaviour with the menu items but I need to inject Project into the breadcrumb trail...
so I click "Projects" in the primary menu which links to /projects. The breadcrumb shows Home » Projects.
Embedded in that page there is another menu "menu-projects" in that menu I click "Informatics".
The trail shows Home » Informatics (and as I step through the secondary menu I get the correct changes to the trail e.g. Home » Informatics » Quality Management Systems
But I want the trail to be Home » Projects » Informatics » etc
I guess I could mess around in template.php as a hacky solution?
Thanks for the help!
Comment #3
MGN commentedOk, so you really don't want the exact menu hierarchy. I don't see an easy way to do this, short of writing some custom code to return the menu title and path for each for each parent/child menu item. Using the 'use php in titles and paths' option, this function could then be used to form the breadcrumb items that you are interested in. Another approach would be to create new tokens that return menu parents and children at different levels. Either approach could work.
What type of pages are you working with in this menu? nodes, views, or ?
Comment #4
gmclelland commentedThis is exactly the problem I was having at http://drupal.org/node/564820#comment-2480074. In my case I was trying to "inject" the word "Departments" in front on the breadcrumb trail. I am trying to do this with nodes.
Comment #5
paul.dambra commentedWell, kinda, the menu is *called* Projects. So I want the menu name in the breadcrumb path and so I guess would need to be able to assign a path to that crumb... although in this case the path is projects.
The site is at http://beta.man.ngrl.org.uk and you can view what I'm aiming for by clicking on the projects link in the navbar
Comment #6
MGN commentedSo perhaps a new feature to optionally add the menu name and assign a path would probably meet everyone's needs here?
Comment #7
gmclelland commented@MGN
In my case I have the following Menu called "HR Department Menu" with three menu items
HR Department
HR Department->Apply for a job
HR Department->Apply for a job->Applications
Here is how I would like my breadcrumbs to look:
Home->Departments->HR Department
Home->Departments->HR Department->Apply for a job
Home->Departments->HR Department->Apply for a job->Applications
Notice how I would like a custom breadcrumb that is prefixed with Home->Departments?
The HR Department has it's on separate menu because I generate all my pathauto url aliases with the [menupath-raw] token. This gives me nice clean urls like mysite.com/hr-department/apply-for-a-job instead of mysite.com/departments/hr-department/apply-for-a-job.
So when I try to set up a custom breadcrumb I choose:
Specific Path= hr-department*
Titles=Departments
Paths=departments/[menupath-raw]
Home->Departments->HR Department /Apply for a job/Applications
instead of
Home->Departments->HR Department->Apply for a job->Applications
notice the slashes instead of the regular breadcrumb arrows
If I set up a custom breadcrumb like this:
Specific Path= hr-department*
Titles=Departments
Titles=HR Department
Paths=departments
Paths=hr-department
then I get
Home->Departments->HR Department
instead of
Home->Departments->HR Department->Apply for a job->Applications
Custom breadcrumbs simply cuts of the breadcrumb
So I think we could either use a way for custom breadcrumbs to prefix the paths or a token to use that would somehow continue the breadcrumb based on the menu structure.
What do you think?
Comment #8
paul.dambra commentedWell it seems that wine and risotto really do solve all problems.
In the code it looks to me like the menu breadcrumb is being set by using the menu_set_active_menu_name() function from core and I'm using the Menu Block module to display my menu within a particular content type...
So I had a flash of "inspiration" and in my menu I created a new root item called Projects (with the appropriate path set) and altered the set-up of my blocks so they displayed the new menu levels rather than starting at root.
And the behaviour is now absolutely perfect (for me).
I won't close the issue in case this isn't a solution for the other posters and I don't have time right now to set up a test site without the menu block module
Comment #9
MGN commentedYeah, you can't go wrong with wine and risotto! I briefly thought of suggesting this (adding Projects to the menu, not the wine and risotto) but then thought might not be ideal to have to modify the menu structure just to get the breadcrumb right. Still, its nice to see it can work out with Menu Block.
Unfortunately, I haven't been able to find another way to prefix the breadcrumb without using a completely different approach for setting a menu-based breadcrumb.
Thanks for sharing your solution!
Comment #10
TripleEmcoder commentedHello, I have almost the exact same need as gmclelland. But no menu-specific hack will work for me, because I would like to create breadcrumbs from: [menupath], [catpath], [termpath]. So a generic option to expand "path" tokens would be great.
Comment #11
MGN commented@memfis, This feature request needs to go the token module issue queue. Custom breadcrumbs uses tokens provided by other modules, but it doesn't create (or modify) any of its own. I agree that new tokens like you describe would be helpful, but it needs to be done in the token module. Please search the token module issue queue for similar issues. If you don't find one, open your own and lets see what can be done.
Comment #12
TripleEmcoder commentedBut the way I undestand it, the token design only allows tokens to be strings, right? So there would still need to be some support from this module. One thing is to split the token on / or similar character and another that a [menupath] token or similar lacks path information, right? So a second token like [menupath-urls] would be needed, and then splitted. Would this be the preferred way to achieve this? Do you have other ideas? I will be happy to post to the token module queue then.
Comment #13
emptyvoid commentedIt would appear that there are two interface elements that might be missing here.
1) Options in the custom breadcrumb settings form
In the taxonomy sub-module an option is available entitled "Show current node title in taxonomy breadcrumb trail".
I would recommend adding a similar feature for the menu path sub-module "Show current node title in menu breadcrumb trail".
2) Options in the node, path rule form
When defining a node, view, or taxonomy breadcrumb rule provide the option to enable or disable the node title per rule. a radio button (which checks if the "Show current node title in menu breadcrumb trail" is enabled). Which states: "Override displaying the current node title in the breadcrumb" Yes|No.
3) Menu Path Separator Special Token
Provide a special token modifier similar to
for the [menupath] token where a user can define the separator value.
Perhaps something like this:
An alternative is add a form field to the node rule form to specify the separator for the menupath token.
Comment #14
MGN commented@emptyvoid, thanks for the ideas.
At the moment, I don't see how to implement your suggestion #1, using the current approach to menu-based breadcrumbs. But if you see how to do this, let me know.
#2 would require modifying the database, which I am not interested in until we have a 6.x-2.0 release, then we can consider it for 6.x-3.x branch.
#3 could work, but its adding code to custom breadcrumbs that would be cleaner to address through tokens. @memfis, tokens do only provide a single string, but its easy enough to provide a set of tokens [menupath-1], [menupath-2], ... [menupath-N] that break apart the components of the [menupath] token. This could then be implemented in custom breadcrumbs (or anywhere else that its needed).
Comment #15
TripleEmcoder commented@MGN: [menupath-N] would imply a constant depth of the menu, what about breadcrumbs for parents? It would result in breadcrumbs like Parent >> Parent >> >> >> (empty tokens at a certain depth).
Comment #16
MGN commented@memfis, If the token returns nothing for the title, the custom breadcrumbs should ignore it - it shouldn't produce empty crumbs. So you can set up your custom breadcrumb for the largest depth possible on your site. I think the argN tokens in the token starter kit might be a good example.
Comment #17
MGN commentedI am going to leave this as postponed in case one of the options in #13 can be further developed, possibly after the release of 6.x-2.0.
Comment #18
derhasi commentedMGN, I'd like to work on this issue. But I'll drive a different approach than the options in #13:
A solution could be by buidling multi-line tokens. One token like
[menutree-paths-newline]could return a list of the paths of the parent menu items:and an associatied token like
[menutree-titles-newline]would return the associated menu link titles:.
For that solution there has to be a way to get multiple lines out of one line in titles and paths. In code this could be done in
custom_breadcrumbs_set_breadcrumb()at arround line 290:<multline>) and additional handling for these lines, so they will build multiple lines.In both cases the user as to put multiline behaviour in each textarea (titles and paths).
Do you think this could be a good solution for the problem? If so I'd write a patch for on of these approaches.
Comment #19
derhasi commentedWith #754494: Provide hooks for modules to provide special identifiers for custom breadcrumbs, capable of building multiple crumbs this issue can be solved.
For a custom implementation I created a "proof-of-concept" module on http://github.com/derhasi/dev/tree/custom_breadcrumbs . there's also a patched version of custom_breadcrumbs.
cb_menuidentifier.module implements a new identifier
<parent-menu-trail>that will set the menu items as breadcrumbs. This works on any menu link available.For example with the example above you could integrate the admin navigation for creating content in the breadcrumb of a node. ( I don't know why some would do that, but it's possible ;) )
Title
Path
Comment #20
MGN commentedThanks for this. I think this is the right way to approach the problem. I'll comment more on the other issue. There is no patch to review on this issue, so I am moving this back to postponed.
Comment #21
derhasi commentedI posted a patch for this issue in #789716: Identifier for menu parent items, so I mark this as duplicate to avoid drifting away discussion.
Sorry I remembered too late, that there was a discussion going on allready.