This is frustrating bc I don't have any idea how breadcrumbs are supposed to work with views. If I have no arguments it just shows the Title of the view as the breadcrumb. If I use arguments it gets all tricked up. It like assumes that you want a top down hierarchy with arguments, but I don't really want that. I don't really want any breadcrumbs really. I'm going to have a bunch of arguments, and they're not a hierarchy. How can I customize these?

Comments

KingMoore’s picture

I am going to be doing custom breadcrumbs here shortly (next week?). I will post my solutions, and check here for yours and others.

What I have been considering doing is to set up path auto to display the correct trail I want to use for my breadcrumbs, then have some hook or maybe template.php (not sure which to use?) assemble the breadcrumb based on the URL path and a bit of hard coded logic.

lipcpro’s picture

Have you guys looked at the custom breadcrumbs module
http://drupal.org/project/custom_breadcrumbs

drupalninja99’s picture

Custom breadcrumbs is good if you want to customize the breadcrumbs when you're viewing a node, but they don't have view integration. View breadcrumbs drive me nuts when dealing with arguments. I created a custom module instead of messing with creating a custom search on top of a view bc it was too much work and not enough control.

danigrrl’s picture

Hi there,

I'm working on a 6 site and I've spent the last four hours trying to get custom breadcrumbs to work. I would love you forever.

All I'm looking for is breadcrumbs that will work based on what menu the link is in. Even MenuTrail and Menu Breadcrumbs hasn't been working.

Dani Nordin
Director of Digital UX, Pegasystems
Author, Drupal for Designers (O'Reilly 2012)
http://tzk-design.com

drupalninja99’s picture

But never fear, it isn't too terrible. In fact you could put all your breadcrumb code in template.php

For it to work right you need to set breadcrumbs in preprocess

function phptemplate_preprocess(&$vars){
}

This will give you access to drupal_get_title().

Here is some sample code of what I did recently:

function phptemplate_preprocess(&$vars){
  //set breadcrumbs
  _phptemplate_set_all_breadcrumbs($vars);
}

/**
 * Set all breadcrumbs
 * 
 * This function is a central place to set breadcrumbs for the entire site
 */
function _phptemplate_set_all_breadcrumbs(&$vars){

  $path = drupal_get_path_alias($_GET['q']);
  $node = menu_get_object('node');
  $node_type = $node->type;
  
  /**
   * First check for node item
   */
  if ($node_type) {
    switch($node_type) {
      case 'ammunition_ballistics':
        drupal_set_breadcrumb(array(l('Home',''), l('Ballistics Chart','ballistics-chart'), l(drupal_get_title(), $path, array('html' => TRUE))));
        break;
      case 'gun':
        drupal_set_breadcrumb(array(l('Home',''), l('Gun Directory','gun-directory'), l($node->title, $path, array('html' => TRUE))));
        break;
      case 'guide_entry':
        drupal_set_breadcrumb(array(l('Home',''), l('G&A Guide','ga-guide'), l(drupal_get_title(), $path, array('html' => TRUE))));
        break;
      case 'article_guns':
      default://default to home and title
        drupal_set_breadcrumb(array(l('Home',''), l(ucfirst($node->current_channel), $node->current_channel), l($node->title, $path, array('html' => TRUE))));
    }
  }
  /**
   * Then check paths
   */
  else {
    //user/my g&a page
    if (preg_match('/^user(\/\d+)?/', $path))
      drupal_set_breadcrumb(array(l('Home',''), l('My G&A', 'user')));
    //user register
    elseif (preg_match('/^user\/register.+/', $path))
      drupal_set_breadcrumb(array(l('Home',''), l('My G&A', 'community'), l('What\'s My G&A?', 'whats-my-ga')));
    elseif (arg(0) == 'admin'){ 
     // don't do anything
    }
    //default
    else {
      drupal_set_breadcrumb(array(l('Home',''), l(drupal_get_title(), $path, array('html' => TRUE))));
    }
  }
}
drupalninja99’s picture

All you need is drupal_set_breadcrumb() and the page path (if we're talking views). This is a convenient workaround when views does something goofy with your breadcrumbs.

avolve’s picture

there seems to be a lot of people seeking assistance with views and breadcrumbs of late (including myself). Thought i would point you to this— #215475: Revamp Custom Breadcrumbs to Support Views, Users, Taxonomy, and Panels

avolve designs | ethical by design