I want to configure breadcrumbs depending on the node type. How can I get the node type in a function theme_breadcrumb in template.php? I try it, but it doe't work.

function zen_breadcrumb($variables) {
    $breadcrumb = $variables['breadcrumb'];
    if($node -> type == 'article'){
        // Adding the title of the current page to the breadcrumb.
        $breadcrumb[] = drupal_get_title();

        // Provide a navigational heading to give context for breadcrumb links to
        // screen-reader users. Make the heading invisible with .element-invisible.
        $output = '<h2 class="element-invisible">' . t('You are here') . '</h2>';

        $output .= '<div class="breadcrumb">' . implode(' › ', $breadcrumb) . '</div>';
        return $output;
  • Just add $node =$variables['node']; and remove space in $node -> type change it to $node->type will work. – berramou Nov 7 '19 at 21:07

Browse other questions tagged or ask your own question.