Created
August 30, 2013 22:38
-
-
Save jeremycaldwell/6394976 to your computer and use it in GitHub Desktop.
Drupal 7 - Breadcrumbs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Implements hook_breadcrumb | |
*/ | |
function THEMENAME_breadcrumb($variables) { | |
$breadcrumb = $variables['breadcrumb']; | |
$crumbs = '<div class="breadcrumb"><div class="wrapper"><ul>'; | |
if (!empty($breadcrumb)) { | |
// Provide a navigational heading to give context for breadcrumb links to | |
// screen-reader users. Make the heading invisible with .element-invisible. | |
$array_size = count($breadcrumb); | |
$i = 0; | |
while ( $i < $array_size) { | |
$crumbs .= '<li class="breadcrumb-' . $i; | |
if ($i == 0) { | |
$crumbs .= ' first'; | |
} | |
if ($i+1 == $array_size) { | |
$crumbs .= ' last'; | |
} | |
$crumbs .= '">' . $breadcrumb[$i] . '</li> >'; | |
$i++; | |
} | |
$crumbs .= '<li class="active">' . drupal_get_title() . '</li></ul></div></div>'; | |
return $crumbs; | |
} | |
else { | |
$crumbs .= '<li class="active">Home</li></ul></div></div>'; | |
return $crumbs; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment