Tell me more ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I'm trying the change the breadcrumb in drupal to show in danish language through the template.php in my theme but i doesn't change it on the site. I've flushed the cache.

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

 <?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;
     }
    }
    ?>

The link to the page www.modeindeks.com

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 at 1:58

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 home link then you should try like this:

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

To know the exact position of element which do you want to add, you can do

<?php var_dump($breadcrumb); ?>

Changed code from Question

<?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.
          $breadcrumb[0] = l(t('Du er her'), 'front'); //Inplace of front you can post url of your site's front page

          $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: ' .  $breadcrumb . '</div>';
  }
}
share|improve this answer
I'm pretty new to drupal so i don't actually know what you mean, the code i've used is just something i've found on stackoverflow. I'm not entirely sure what you mean, can you please insert the lines in my code so I can fully understand. Thanks – MyRevenge Dec 5 '12 at 9:02
Added the code..check it out – mohit_rocks Dec 5 '12 at 9:12
modeindeks is your theme name ? – mohit_rocks Dec 5 '12 at 9:14
Yes it is the theme name but in the .info file it is ModeIndeks. I can't get your code to work, it's the only template file i can't get to work and i don't know why. Do i need to call it somewhere? – MyRevenge Dec 5 '12 at 9:56
where are you writing this code – mohit_rocks Dec 5 '12 at 10:47
show 1 more 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.