Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6568391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:28:19+00:00 2026-05-25T14:28:19+00:00

Drupal 7: function THEMENAME_breadcrumb($variables) { $breadcrumb = $variables[‘breadcrumb’]; if (!empty($breadcrumb)) { // Provide a

  • 0

Drupal 7:

 function THEMENAME_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="element-invisible">' . t('You are here:') . '</h2>';
    $crumbs = '<ul class="breadcrumbs clearfix">';
    $array_size = count($breadcrumb);
    $i = 0;
    while ( $i < $array_size) {
      $crumbs .= '<li class="breadcrumb-' . $i;
      if ($i == 0) {
        $crumbs .= ' first';
      }
      if($i != 0 && $i+1 != $array_size ) {
        $crumbs .= ' middle';
      }
      if ($i+1 == $array_size) {
        $crumbs .= ' last';
      }
      $crumbs .=  '">' . $breadcrumb[$i] . '</li>';
      $i++;
    }
    $crumbs .= '</ul>';
    return $crumbs;
  }
}

This outputs the breadcrumbs in the format I need other than I need to add span tags around the text inside the link.

The link is being written in the seventh line from the bottom:

  $crumbs .=  '">' . $breadcrumb[$i] . '</li>';

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T14:28:20+00:00Added an answer on May 25, 2026 at 2:28 pm

    Since I can’t see the content inside of $breadcrumb[$i] I can’t be completely sure that this will work, but the following code should work for you as it wraps anything inside an anchor tag with a span tag:

    preg_match("@<a ([^>]+)>(.+)</a>@i", $breadcrumb[$i], $matches);
    $crumbs .=  '"><a ' . $matches[1] . '><span>' . $matches[2] . '</span></a></li>';
    

    Just replace the seventh line in your function with these 2 lines and see if it works! Otherwise, use var_dump on $breadcrumb[$i] and add the result to your question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a drupal function or convention for including JavaScript onto a page or
What function in Drupal gets file attachment path? Edit: the attachments provided by Upload
Is there any function in Drupal like get_module_info('MODULE_NAME') or I should parse info file?
Drupal has a print link function that I'm using in my .tpl.php <?php print
In drupal 6 I'm trying to execute a function on every page and output
Drupal Aggregator core module is a useful one but suffers many problems. There are
Drupal is very much a Do Everything CMS. There are modules that allow you
My drupal site (internal) will not display the TinyMCE editor when using Google Chrome
I have Drupal 5 site where a button is clicked and it calls a
I'm running Drupal 5 on my website and want to upgrade to V6. I've

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.