1

I am using the Path Breadcrumbs module to create breadcrumbs. I don't fully understand how to use arguments and selection rules, and thus I'm not sure how to create the following breadcrumb:

On the gallery node page (/gallery/%node), I want to use home > events >[event-name] > schedule as breadcrumbs.

Every Event node contains a node reference to a gallery node. I am trying to add this event name to the breadcrumbs. I already have retrieved the event name from $variables, following How do I retrieve node data for a referenced node in a template file?

2 Answers 2

0

As an last option you can implement theme_breadcrumb() in your theme template.php

Something like below sample code.

function themename_breadcrumb($variables) {
  if (arg(0) == "galery" && is_numeric(arg(1))) {

    // Get event title of the  event
    $event_nids = mymodulename_get_back_refernce_value(arg(1));

    // Note since a gallery can be referred by multiple event nodes so you have add logic which one you need to pick here, for now I am picking with array index as 0
    $event_node = node_load($events_nids[0]);

    $links[0] = l(t('Home'), '<front>');

   // inplace of 'events' add internal link path to events page.
    $links[1] = l(t('Events'),'events');
    $links[2] = l(t($event_node->title),'node/'.$event_node->nid);
    $links[3] = t('schedule');
    drupal_set_breadcrumb($links);
  }
}
3
  • I tried your code, with a few changes - if (arg(0) == "gallery") - and - $event_nids = get_back_reference_value($variables['node']->nid); but nothing happened. I changed the name to my theme name and flushed the cache, but I don't think the code is ever being picked up. I tried a drupal_set_message and it never displayed either. Commented Oct 15, 2013 at 15:41
  • do you have devel installed?
    – arpitr
    Commented Oct 15, 2013 at 16:07
  • @user1015214 can you join this chat room chat.stackexchange.com/rooms/11070/breadcrumb
    – arpitr
    Commented Oct 15, 2013 at 16:15
0

The Path Breadcrumbs module works with system paths. For nodes system path looks like node/%, you can read more in the module FAQ and documentation.

The main problem with your example is that your Gallery content type doesn't have a reference field to Event, so other modules don't know if this Gallery node is referenced from that Event node.
There is a list of modules which may help with it on How do I implement two-way node references? (I didn't test them.)

Another way is to provide a computed entity property "Event" for Gallery content type with hook_entity_property_info_alter(). Doing so, your property will be available as a token in Path Breadcrumbs.

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.