Skip to main content

How To Add Current Page To Breadcrumbs in Drupal 7

By February 14, 2017Blog, CMS, Drupal
Allure Web Solutions Code Snippet

By default, Drupal 7 doesn’t include the current page in the breadcrumbs trail. The snippet below shows how to add the current page to the breadcrumb in Drupal 7. The current page will remain unlinked.

<?php
function THEME-NAME_breadcrumb($variables)
{
    $breadcrumb = $variables['breadcrumb'];
    // If breadcrumbs are activated
    if (!empty($breadcrumb)) {
        $title = drupal_get_title();
        if (!empty($title)) {
            $breadcrumb[] = $title;
        }
        return '<div class="breadcrumb">' . implode(' › ', $breadcrumb) . '</div>';
    }
}

Where THEME-NAME is the name of your theme. This code will auto-execute as it hooks into your theme.

Add this snippet to: theme_folder/themes/breadcrumbs.theme.inc

allure

Author allure

More posts by allure

Leave a Reply

Designed by

best down free | web phu nu so | toc dep 2017