I was asked to use the Hansel breadcrumbs module to derive the breadcrumbs in a site, but I hardly understood the flow of the module. I cannot get a clear picture even from the modules documentation. I would appreciate any help to clarify my doubts about this module.

  • I have removed a custom breadcrumb module, and installed the Hansel breadcrumbs module.
  • I want to create breadcrumbs in specific page like Home->Bussiness->Faq and so on.

How is this possible with the Hansel breadcrumbs module?

  • I don't know this module, but it seems to be a complicated beast. Did you try to check the support requests in its issue queue ?
    – Countzero
    May 21, 2012 at 10:05
  • Currently I am using Custom breadcrumb to achieve the breadcrumbs. But based on a requirement i need to use only hansel module. I have created rules but when i use "switch" i find no way to use "Switch on node type". How does this module know when and where to switch on any node tyep?
    – Gladiator
    May 22, 2012 at 4:58
  • As I said before, I don't know this module, and won't learn it for you. I just tried to put you on the right track to find the information you need. Given the lack of answers to your question, people don't seem to have it, so the issue queue should be the better place to go.
    – Countzero
    May 22, 2012 at 6:11
  • Better read the documentation to know more about the configuration in hansel module.
    – user4081
    Jul 18, 2012 at 11:09

2 Answers 2


"Switch on node type" is like a switch($case){} statement in PHP (and other languages).

After selecting "Switch on node type" in Hansel, you will need to provide the *machine_name* of the node-type in the "Name" field that Hansel presents. For instance, you can enter one of the following in the "Name" field:

  • article -- will target Article nodes
  • blog_entry -- will target Blog Entry nodes
  • webform -- will target Webform nodes
  • <default> (for remaining node types)

If it were in code, it would look something like:

switch($node->type) {
  case 'article':
    // Make an article crumb
  case 'blog_entry':
    // Make a blog-entry crumb
  case 'webform':
    // Make a webform crumb
  case '<default>':
    // Do something for everything else...

"Switch on path argument" works the same way... but, instead of providing a node-type in the "Name" field, you should enter the path-argument you're targeting, such as:

  • node (to control breadcrumb on pages with a path like node/*)
  • taxonomy (i.e. for taxonomy/term/* pages)
  • admin (i.e. admin/* pages)
  • blogs (i.e. blogs/* pages)

$path_arg_1 = arg(0);

switch($path_arg_1) {
  case 'node':
    // Make a crumb for node/* pages
  case 'taxonomy':
    // Make a crumb for taxonomy/* pages
  case 'admin':
    // Make a crumb for admin/* pages
  case 'blogs':
    // Make a crumb for blogs/* pages

It seems Hansel can only target the first path-argument. Also note that <default> seems to only work for "Switch on node type".

To create Home->Bussiness->Faq->How To Tie a Tie (assuming Business is a tax-term and Faq is node-type):

  1. First Rule (for the breadcrumb's head, i.e. "Home" link)
  2. Create a rule with the name start, and leave "Parent" set to <root>
  3. Under "action with breadcrumb", select "add a single link"
  4. Set "Action" to "switch", then click "next"
  5. Enter "Home" as your link name, then set path to <front>
  6. Select "switch on url argument" and click "save"
  7. Second Rule (for the breadcrumb's tail, i.e. node-title: "How To Tie a Tie")
  8. Create a rule with the name finish, and leave "Parent" set to <root>
  9. Under "action with breadcrumb", select "add link to current page"
  10. Set "Action" to "leave", then click "next" and "save"
  11. So far, these two rules will get you: Home->How To Tie a Tie
  12. Third Rule (for the second crumb, i.e. taxonomy term "Business")
  13. Create a rule with the name node, and set "Parent" to -start
  14. Under "action with breadcrumb", select "add term path"
  15. Set "Action" to "switch", then click "next"
  16. On the next page, select the vocab containing the "Business" term
  17. Set "Switch on" to "node type" then click "save"
  18. Fourth Rule (for the third crumb, i.e. node-type "Faq")
  19. Create a rule with the name faq (for node type "FAQ"), and set "Parent" to --node
  20. Under "action with breadcrumb", select "add link to nodetype"
  21. Set "Action" to "Goto rule", then click "next"
  22. On the next page, configure the "Path" as desired
  23. Set the "Goto Destination" to -finish then click "save"

In my opinion at the current state hansel is way to complicated and limiting, I ran into multiple problems:

  • dealing with taxonomy
  • entity reference
  • token issues (which was more a problem to token itself and entity reference)
  • addind a custom link to something based on little logic and a given field (php processing is for switch only, not for action why? besides it is a bad idea to use php in that way anyway)
  • ordering problems of added terms.

Actually I spend dealing 5 hours messing around with hansel to end up writing a custom breadcrumb building within one hour.

It is too complicated for a site builder / non developer and too limiting for a developer. see http://drupal.org/node/805874 for further reference and discussion.

roundup: do not use it, maybe take its code as a reference for building a own module:

 * Implements hook_theme_registry_alter().
function my_module_theme_registry_alter(&$theme_registry) {
  $theme_registry['breadcrumb_original'] = $theme_registry['breadcrumb'];
  $theme_registry['breadcrumb']['function'] = 'my_module_get_themed_breadcrumbs';

function my_module_get_themed_breadcrumbs() {
  $breadcrumbs = my_module_get_breadcrumbs();
    if (is_array($breadcrumbs)) {
      return theme('breadcrumb_original', $breadcrumbs);
    return theme('breadcrumb_original', $original_breadcrumbs);

function my_module_get_breadcrumbs() {
  switch (drupal_strtolower(arg(0))) { // node/$x, taxonomy/$x ...
    case 'node': // node/$x
      if (is_numeric(arg(1))) {
        if ($node=node_load(arg(1))) {
          switch ($node->type) {
            case 'article':
              _my_module_link_taxonomy($links, $node, 'field_tags');
              _my_module_link_node($links, $node);
    case 'taxonomy':
    case 'admin':
    case 'user':
      //extend by your own rules
      return null;

  $last_item_link = variable_get('my_module_breadcrumb_last_item_link', TRUE);
  foreach ($links as $key => $link) {

    if (is_array($link)) {
      switch ($link['href']) {
        case '<none>':
          $breadcrumbs[$i] = check_plain($link['title']);
        case '<front>':
          $breadcrumbs[$i] = ($last_item_link || $i != $last_item_number) ? l($link['title'], '') : check_plain($link['title']);
          $breadcrumbs[$i] = ($last_item_link || $i != $last_item_number) ? l($link['title'], $link['href']) : check_plain($link['title']);
  return array('breadcrumb'=>$breadcrumbs);

function _my_module_link_node(&$links, $node, $key=null) {
  if (is_null($key)) {
  $links[$key] = array(

function _my_module_link_taxonomy(&$links, $node, $field) {
  // check if the node has classification settings
  if (!empty($node->{$field})) {
    foreach ($node->{$field}['und'] as $tid) {

    if (!empty($terms)) {
      // find a term with parent items, taxonomy_get_parents_all() will
      foreach ($terms as $term) {
        if (count($parents)>1) {
          // notice $parents contains the parents
          // notice $term contains a term with a parent item

      // no hierarchical term found, take the first one from array
      if (is_null($term)) {

      $link = array();
      $link[$term->tid] = array(
        'title' => $term->name,
        'href' => 'taxonomy/term/' . $term->tid,
      #$parents = taxonomy_get_parents_all($term->tid);
      foreach ($parents as $parent) {
        $link[$parent->tid] = array(
          'title' => $parent->name,
          'href' => 'taxonomy/term/' . $parent->tid,
      foreach (array_reverse($link) as $tid => $value) {
        $links[$tid] = $value;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.