This is a proposal to revamp the Custom Breadcrumbs module for 5.x-2.x-dev and 6.x-2.x-dev.

The Problem

In its current state, Custom Breadcrumbs only provides custom breadcrumbs for nodes. If we want to create a custom breadcrumb for a View, we're out of luck.

The Solution

In order to get more customization within the breadcrumb, we'd have to extend the Custom Breadcrumbs API to expose hooks that would allow breadcrumbs to be created for:

  • Views
  • Users
  • Taxonomy terms
  • Nodes
  • Panels

With this extended API, we could effectively get the "custom" back in "custom breadcrumbs" (credits for this horrendous pun go to Jeff Eaton).

The Implementation

For this extended API, we'd have to create a hook that would allow modules to:

  1. Display information about the breadcrumb type that the user would be overriding (View, Node, Panel, User, etc)
  2. Show settings for that custom breadcrumb type (node type, view name, panel name, etc)

Modules that would add custom breadcrumb types (like Custom Node Breadcrumbs, Custom Views Breadcrumbs, Custom User Breadcrumbs, etc), would implement this hook, and also apply the custom breadcrumb when necessary. The Custom Node Breadcrumb, for example, would apply the breadcrumb on hook_nodeapi. The Custom User Breadcrumb, would apply the breadcrumb on hook_user($op = 'view').

Having this setup would effectively let us create custom breadcrumbs for anything. Be it a view, a panel, a user, a taxonomy term, a node, it wouldn't matter, as we would just use the Custom Breadcrumbs API to create a custom breadcrumb for that item.

Thoughts greatly appreciated.

CommentFileSizeAuthor
#16 sections_interface.png10.31 KBKingMoore

Comments

eaton’s picture

As we discussed in #drupal, I think I still have some significant concerns about this. First, there's no central core API for modifying breadcrumb trails (there's no hook_breadcrumb_alter, for example), so there are quite a few tricky questions about how some of those things would be overridden.

And that's the trick: each one of these types would require what amounts to a separate module. The edit fields, stored data for the breadcrumb, and the technique for performing the actual override (hook_nodeapi, hook_menu, theme overrides, etc.) would be different for each kind of data. I'm not sure that turning this module into a central 'hub' for that is worthwhile; wouldn't it make just as much sense to make modules to override those other things?

I want to emphasize that I'm not inherently opposed to it, I'm just concerned about the bloat that could easily occur. The module is already putting some overhead on things compared to writing a relatively simple custom nodeapi module for a site (ie, token parsing, loading breadcrumb records from the db)...

druvision’s picture

Custom node API only works for programmers, not for the rest of us.
A helper UI, like for themes, might be helpful.

Subscribing.

scottrigby’s picture

Subscribing - however it can be accomplished, it's a task to customize breadcrumbs especially for Views. (I would also say taxonomy categories, but these can be handled by views too).

So any advice about how to deal with breadcrumbs for Views would be greatly appreciated! (even if it is a small add-on, separate module, patch, some other workaround, etc).

Thanks in advance for any advice!
:)
Scott

OwnSourcing’s picture

subscribing

scottrigby’s picture

*bump*? :)

Dimegga’s picture

Suscribe...

realityloop’s picture

subscribe

quinnanya’s picture

subscribe

scottrigby’s picture

In the meantime, there's a way to do this using workflow_ng (another great module by the way!). The recent version includes "Set Breadcrumb" action. The condition to check if it's a particular view is done with a 'Execute custom PHP code' condition.

In my case, I already set paths for sub categories using pathauto, and I wanted to set corresponding breadcrumbs for each category in the default 'taxonomy_term' view. Here was my custom PHP code to check that the view is 'taxonomy_term' AND the url included 'services':

// this seems to prevent too many redirects
$match = FALSE;

// this gets the url of the current page
$url = request_uri();

// this gets the current view
global $current_view;

// this sets to TRUE if url contains 'services' (whether or not the url is capitalized) AND is the view 'taxonomy_term'
if ((strpos($url, "services") || strpos($url, "Services")) && ($current_view->name == 'taxonomy_term') ) {
  $match = TRUE;
}

// This returns either TRUE or FALSE
return $match;

If the code returns TRUE, the condition is met, and the action is set. If FALSE, nothing happens.

So my action I added 'Set Breadcrumbs' and in my case I just added the manual word 'contractors' on both lines, just as you would in custom breadcrumbs (I didn't use tokens here because my need was very specific, but token support is included).

So I hope that helps someone if you need it in the meantime, before this gets implemented in custom breadcrumbs.

:)
Scott

fago’s picture

here you can find something more about the solution referred by scottrigby: http://more.zites.net/workflow-ng/2-0-released-and-customized-breadcrumbs

stevekerouac’s picture

subscribe. custom breadcrumbs for views = necessary

halfiranian’s picture

subscribing too.. haven't yet found a solution getting my breadcrumbs sorted when using views

rszrama’s picture

subscribing

More flexible custom breadcrumbs... cool. Breadcrumbs for Views? Use some PHP in the header of the View page... (Sorry, I know that requires coding... but it works like a charm. : )

btw, Rob, if you're even still planning to follow through with this proposal, are you considering custom breadcrumbs based on node type?

davedelong’s picture

subscribing

KingMoore’s picture

StatusFileSize
new10.31 KB

Hello, I totally support adding power to the custom breadcrumb module (hence the reason I searched and found this topic in the first place). Having the breadcrumb 'customization' limited to node types doesn't help me a whole lot, as I have a lot of other customization I need to do that can't simply be defined based on node type.

An example of breadcrumb functionality I specifically need is: the ability to set different breadcrumbs per node type depending if that node type has group context. If the node is not associated to any group, the breadcrumb trail must be completely different than if the node has group context.

Anyways, I don't like the hook implementation suggested in the first post. I agree with Eaton's sentiments, and also this type of implementation would put users of 'custom breadcrumbs' at the mercy of what the developers decide needs to be supported by 'custom breadcrumbs'.

Possible Solution
Why can't we implement a much more powerful matching UI than the simple dropdown of node types? It seems to me it should be relatively simple to implement something like the sections module has implemented for matching (http://drupal.org/project/sections), and then apply the breadcrumbs in the same way.

The sections module allows you to match based on a path (wildcards allowed) or to match based on PHP code input. This would allow users of 'custom breadcrumbs' to literally match on anything they wanted, and then specify a breadcrumb for that match. For instance I could solve my example above simply like this:

Match Breadcrumb on PHP Code:

  if (arg(0) == 'node' && is_numeric(arg(1))) {
    $nid = arg(1);

    $node = node_load($nid);

    if($node->type = 'type_to_match' && og_get_group_context()){
      return TRUE;
    }

  }

I could then specify my breadcrumb exactly like custom breadcrumbs does now.

We could also use path matching (as in Sections module) to create a breadcrumb for a specific view (or whatever) based on path. The options would be limitless if 'custom breadcrumbs' gave us the power.

I am attaching a screenshot of an interface like I am talking about. We could leave the node type dropdown as an option as well.

avolve’s picture

subscribing (views and custom breadcrumbs)

robloach’s picture

The problem with taking over a page is that you don't know what's being displayed, so you don't know where to get information from. This is where context comes in and what Earl Miles was working on with Panels 2. If you had a user interface that allowed you to stick in your own URLs along with some context about what's being displayed, then we could go somewhere... Something like the menu system (node/%node, user/%user, etc).

silurius’s picture

Subscribing.

halfiranian’s picture

subscribing too. custom breadcrumbs is awesome and having it work for my Views too would end my breadcrumb misery :(

doc2@drupalfr.org’s picture

subscribing

filiptc’s picture

Hell, yes. Subscribing.

KingMoore’s picture

So when do we get to put the custom back in custom breadcrumbs?

:-D

CSCharabaruk’s picture

Subscribing. This is really needed.

dirtabulous’s picture

subscribing

neyoung’s picture

subscribing

maximago’s picture

subscribing

phpsharma’s picture

yes we need it

dydecker’s picture

subscribing

greenskunk’s picture

subscribing

betz’s picture

subscribing

sonictruth’s picture

subscribing

mrfelton’s picture

subscribing

bejam’s picture

subscribing

lelizondo’s picture

I came up with a solution for this: http://drupal.org/node/319857.

Luis

betz’s picture

nice

doc2@drupalfr.org’s picture

I've been waiting for so long before this first by_hand solution! So very nice indeed, in the waiting of an integrated solution.

traviscarden’s picture

Title: Custom Breadcrumbs Revamp » Revamp Custom Breadcrumbs to Support Views, Users, Taxonomy, and Panels

This is something I've wanted for awhile now. As it appears to be such a popular request I'm updating the title to make sure everyone who's looking for it recognizes it (so we don't end up with a lot of duplicates).

babbage’s picture

Version: 5.x-1.2 » 6.x-1.4

I don't care how it is administered, but having a logical breadcrumb path for every page on a site, regardless of how it is created, is critical and should be made easy.

Subscribing.

Flying Drupalist’s picture

subscribe

curagea’s picture

Subscribing

fasdalf@fasdalf.ru’s picture

There are abandoned http://drupal.org/node/313872 Taxonomy_breadcrumb. If Custum breadcrumbs will do the same thing with tasonomy/term pages as taxonomy breadcrumb (http://drupal.org/node/339715) does it willl be great!
So, subscribing.

psordi’s picture

subscribe

freefontaine’s picture

subscribing - I just had to do this with an override in template.php to set a custom breadcrumb for a view page

scottrigby’s picture

@#39 & #42 - it would be nice :)

For anyone interested in breadcrumbs/views integration for custom breadcrumbs - you might want to test the patch here: http://drupal.org/node/323816#comment-1082064 (sounds like you may need to increase the module weight as explained in #18 in that issue).

For the meantime, methods in #10/11 above still work with workflow_ng in D5, and the same methods work in D6 with Rules.

hankpalan.com’s picture

Subscribing...

mandclu’s picture

One more subscriber. Panels support would be huge for me.

scedwar’s picture

subscribe

jjma’s picture

subscribe

scroogie’s picture

subscribing.

manoloka’s picture

subscribing

notebene’s picture

subscribe

EastWan’s picture

subscribe

oliverpolden’s picture

subscribing

UniqID’s picture

subscribing...

edjay’s picture

subscribing

jrabeemer’s picture

So who's taking this feature on?

MGN’s picture

See #372648: Custom Breadcrumbs 2.x for a thread to discuss how to implement cb 6.x-2.0. I haven't got much of a response from anyone yet, but I've made some progress including a core cb module (with a start on a cb api that module developers can implement), a views submodule, and a specific path submodule. I am working on a taxonomy submodule, and hoping someone else will want to write a panels submodule. Feedback is welcomed.

jrabeemer’s picture

Panels can be sort-of mangled to work with custom breadcrumbs. The whole point is to trigger the node hook. Things that aren't a node, as the title states, don't trigger these hooks.

But, a node overridden (node/%) panels page can work. On a panels page content tab, add "Node Content" type to a pane, check on "Node page" and uncheck "No extras". This trigger's the proper node hooks. It also triggers blocks as well.

doc2@drupalfr.org’s picture

Just noticed now.... it's for d6... please think of a possible backport!!! Many thanks in advance!

scedwar’s picture

Useful comments on og breadcrumbs here http://drupal.org/node/407578

gjangelo’s picture

I found this post from googling, and saw that there were some 5.x fixes, and a lot of subscribers, but no real solution.

I don't have a solution that is the cure to the views module inadequacy, but I did find a temporary/kludge/hack solution that may be helpful to others that find this page in a search.

I have a content type "job-postings" that populates pages at the path:
company/careers/job-postings/{node-title-here}

The Views page that has only the title listed (link to full nodes) has the path:
company/careers/job-postings

I needed to get custom breadcrumbs on my Views page, "company/careers/job-postings"

So...

I added this to my page.tpl.php file before the call for the $breadcrumb:

$alias = drupal_get_path_alias($_GET['q']);

if ($alias == "company/careers/job-postings") {
$breadcrumb = "<div class=\"breadcrumb\"><a href=\"/\">Home</a> &gt; <a href=\"/company\">Company</a> &gt; <a href=\"/company/careers\">Careers</a> &gt; Job Postings</div>";
}

It checks the url of the path alias, and if it matches the value that I created in "Views > Page > Page Settings > Path", it substitutes my 'flat' values in the $breadcrumb variable. If there is no match, it falls through to the existing $breadcrumb value which may be "Home > {node-title-here}", but it won't show an ugly error.

Of course, the If statement can be extended to check for 'if else', 'if else' & 'else' values to allow for more Views to have breadcrumbs.

The solution works for my installation because my client will not have access to administer the Views or PathAuto settings, which is where the values that I am checking against are coming from.

MGN’s picture

Hi Lrrr. custom breadcrumbs 6.x-2.x supports breadcrumbs for views, taxonomy terms and vocabularies, paths, nodes and panels (under construction now) - see the custom breadcrumbs project page. It is still in development, but testing would be helpful. I will close this issue once a stable release is ready.

Thanks

MGN’s picture

Version: 6.x-1.4 » 6.x-2.0-beta1
Status: Active » Fixed

Marking this issue as fixed now that custom breadcrumbs 2.0 has an official beta release which includes all of these features (except users, but that can now be added easily).

betz’s picture

Ow man, nice to know!
Good job!!

lion123’s picture

I have hierarchy set like this (example):

red
blue
green

These colors are terms and all of them are displayed like views. I have created custom breadcrumbs for them, but they are only displayed as flat hierarchy. For example, when I open blue, breadcrumb trail shows:

Home - blue

But it should display:

Home - red - blue

Is there a solution for this?

Thank you in advance

MGN’s picture

@lion123. I'll be happy to help you out on this, but please open a new issue for your support request. Be sure to indicate what kind of custom breadcrumb you have tried to set up (sounds like you are using custom_breadcrumbs_taxononmy ?), what type of page the breadcrumbs are intended for (node, taxonomy term page, view, panel, etc.) what options you have enabled under custom breadcrumbs settings, what custom breadcrumb modules you have enabled, and what you have entered (if anything) for titles, paths, etc. on the add custom breadcrumb form. Thanks.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

dkane’s picture

OH MY GOD.

THANK YOU THANK YOU THANK YOU!

I have been trying to figure this out for months now and have been pulling my hair out.

Actually it was the only thing keeping me from taking my site live. Then I downloaded 2.0-beta1 and its like the heavens opened up. I fixed all of my problems in about 5 minutes.

Thank you so much. It is much much appreciated.

Stomper’s picture

Great work. Is the current 6x 2.0 beta 3 version safe for a production site?

MGN’s picture

Please try 6.x-2.0-RC1. There have been a lot of fixes since 6.x-2.0-beta3 was released. Should be stable enough for production, but I would still recommend further testing.

benlotter’s picture

Subscribe.... trying to set the argument breadcrumb to Vocabulary / Taxonomy Term / Node Title within my view. Do I need another module to do this?