Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I'm trying to change the breadcrumb in Drupal to display in Danish through the template.php in my theme, but I cannot change it. I've flushed the cache.

This is what I've put in the template.php.

  function modeindeks_breadcrumb($variables) {
    $breadcrumb = $variables['breadcrumb'];

    if (!empty($breadcrumb)) {
      // Provide a navigational heading to give context for breadcrumb links to
      // screen-reader users. Make the heading invisible with .element-invisible.
      $output = '<h2 class="polle">' . t('Du er her') . '</h2>';

      $output .= '<div class="breadcrumb">' . implode(' › ', $breadcrumb) . '</div>';
      return $output;
     }
    }
share|improve this question
    
What parts of the breadcrumb are you trying to change? The breadcrumb links themselves or just the "You are here" text that is the heading of the breadcrumbs? –  rooby Feb 2 '13 at 1:58
add comment

1 Answer

Breadcrumb is made up of an array. So to add any element in the breadcrumb you have to give the offset.

So if you want to set t('Du er her') in place of the front page link then you should try this:

$breadcrumb[0] = l(t('Du er her'), 'front');

To know the exact position of element which do you want to add, you can use var_dump($breadcrumb).

I would rewrite the code as follows.

function modeindeks_breadcrumb($variables) {
  $breadcrumb = $variables['breadcrumb'];  

  if (!empty($breadcrumb)) {
    // Provide a navigational heading to give context for breadcrumb links to
    // screen-reader users. Make the heading invisible with .element-invisible.
    // Instead of front, you can use the URL of your site's front page.
    $breadcrumb[0] = l(t('Du er her'), 'front'); 

    $output .= '<div class="breadcrumb">' . implode(' › ', $breadcrumb) . '</div>';

    return $output;
  }
}

If you want to add only You are here link then use the below code.

function modeindeks_breadcrumb($breadcrumb) {
  if (!empty($breadcrumb)) {
    return '<div class="breadcrumb">You are here: ' . implode(' › ', $breadcrumb) . '</div>';
  }
}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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