3

I'm trying to move the breadcrumb from one part of my theme to another, and they have different template files (using an Omega subtheme). $breadcrumb seems to be an array. I've tried l($breadcrumb) and theme($breadcrumb) to no avail. How do you print out a properly themed and string-ified breadcrumb in a template?

Here's my code btw.

<?php 
function rescue_breadcrumb($variables) {
    $breadcrumb = $variables['breadcrumb'];
    if (!empty($breadcrumb)) {
    $crumbs = '<ul class="breadcrumbs">';
    foreach($breadcrumb as $value) {
       $crumbs .= '<li>'.$value.'</li>';
       }
       $crumbs .= '</ul>';
    }
      return $crumbs;
  }
$breadcrumb = drupal_get_breadcrumb();
if ($breadcrumb): ?>
  <div id="breadcrumb" class="grid-<?php print $columns; ?>"><?php print $breadcrumb; ?></div>
<?php endif; ?> 
3

theme_breadcrumb() would probably be the best choice:

print theme('breadcrumb', array('breadcrumb' => $breadcrumb));

It expects the breadcrumb variable to be an array, each item of which makes up one part of the breadcrumb trail. So this array:

$breadcrumb[] = l('Home', '<front>');
$breadcrumb[] = l('Page', 'page');
$breadcrumb[] = l('Subpage', 'page/subpage');

will produce:

Home > Page > Subpage

You can also use plain text instead of links for the breadcrumb items in case you need to.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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