Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add breadcrumb?

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);         
}
like image 572
Umar Adil Avatar asked Apr 10 '12 10:04

Umar Adil


People also ask

How do you add breadcrumbs to react?

Method 1: By Using the react-router-dom Library With the react-router-dom library, you can manually create breadcrumbs for every path in your React application. The library provides a <Link> component that can be used to create breadcrumbs. export default Breadcrumbs; There are different types of hooks in React.

What is Breadcrumbing in dating?

But have you heard about breadcrumbing? “In a relationship context, breadcrumbing refers to a person who gives you just enough 'crumbs' of attention or affection to give you hope and keep you on the hook — but not enough to make you feel comfortable or assured the relationship is going well,” explains Dr.

How do I find breadcrumbs on my website?

You also see them in Web applications that have more than one step, where they function similar to a progress bar. In their simplest form, breadcrumbs are horizontally arranged text links separated by the “greater than” symbol (>); the symbol indicates the level of that page relative to the page links beside it.


1 Answers

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

like image 163
Muhammad Reda Avatar answered Sep 20 '22 02:09

Muhammad Reda