1

I have implemented breadcrumbs in Drupal 7, using the following code in mytheme.inc file. It is working fine for all the custom pages but for a particular content type lets say CT1, I have url alias setup as homepage/page2/page3/[node:title] so the breadcrumb trail display as homepage > page2 > page3 > title of content but it is only displaying as homepage > title of content. Please advise what I am missing here to make it work the way I want.

function mytheme_breadcrumb($variables)
{
    $breadcrumb = $variables['breadcrumb'];
    $crumbs = null;
    if (!empty($breadcrumb)) {
        $array_size = count($breadcrumb);
        $i = 0;
        while ($i < $array_size) {
            $crumbs .= '<li>' . $breadcrumb[$i] . '</li>';
            $i++;
        }
        $crumbs .= '<li class="active">' . menu_get_item()['title'] . '</li>';
        return $crumbs;
    } else {
        return '<li class="active">Homepage</li>';
    }
}
0

You might want to try a community solution for this like breadcrumbs by path

Your custom function isn't doing anything with the url path itself, it's just using the breadcrumb variable. You can get the path with:

$_SERVER['HTTP_HOST'] . request_uri();

Then you could split by '/' and use drupal_set_breadcrumb to set it.

0

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.