5

How can I add breadcrumb to a page in my attendance module.

I have used the following hook, but it changed the breadcrumb for all pages in other modules also.

function attendance_init() {
// set the breadcrumb
$breadcrumb = array();
$breadcrumb[] = l('Home', '<front>');
$breadcrumb[] = l('People', 'group/node/'. arg(2) .'/people');
$breadcrumb[] = l('Attendance', 'group/node/'. arg(2) .'/people/attendance');
drupal_set_breadcrumb($breadcrumb);         
}
Muhammad Reda
  • 26,379
  • 14
  • 93
  • 105
Umar Adil
  • 5,128
  • 6
  • 29
  • 47
  • 1
    There's a SO spin off just for Drupal related questions: http://drupal.stackexchange.com/ – Paul Apr 10 '12 at 10:40

1 Answers1

5

If you are trying to change the breadcrumb for a specific content type nodes, try to use hook_node_view_alter()

Here's an example:

function attendance_node_view_alter(&$build)
{
    $node = $build['#node'];
    if($build['#view_mode'] == "full" && $node->type == "attendance")
    {
        $breadcrumb = array();
        $breadcrumb[] = l('Home', '<front>');
        $breadcrumb[] = l('People', 'group/node/'. arg(2) .'/people');
        $breadcrumb[] = l('Attendance', 'group/node/'. arg(2) .'/people/attendance');
        drupal_set_breadcrumb($breadcrumb);
    }
}

Hope this works... Muhammad

Muhammad Reda
  • 26,379
  • 14
  • 93
  • 105
  • Thanks Muhammad for your help. I have implement this by some other way. – Umar Adil Apr 12 '12 at 06:20
  • 9
    Umar next time do you mind posting how you implemented your way of fixing it, instead of accepting an answer? This is usefully because it allow you to explain how you fixed your issue which may in return help future users. – John Riselvato Sep 10 '12 at 08:39