Skip to content

Instantly share code, notes, and snippets.

@Aeotrin
Created July 20, 2016 18:57
Show Gist options
  • Save Aeotrin/7d1654b1829f6770a2a51376ebb80913 to your computer and use it in GitHub Desktop.
Save Aeotrin/7d1654b1829f6770a2a51376ebb80913 to your computer and use it in GitHub Desktop.
Drupal 8 - Breadcrumb Preprocess and Cache
function theme_preprocess_breadcrumb(&$variables) {
if (($node = \Drupal::routeMatch()->getParameter('node')) && $variables['breadcrumb']) {
$variables['breadcrumb'][] = [
'text' => $node->getTitle()
];
$variables['#cache']['contexts'][] = 'url.path';
}
}
function theme_preprocess_breadcrumb(&$variables) {
if (($node = \Drupal::routeMatch()->getParameter('node')) && $variables['breadcrumb']) {
$variables['breadcrumb'][] = [ 'text' => $node->getTitle() ];
}
}
@Takiyuddine
Copy link

thank you for that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment