breadcrumb
This commit is contained in:
@@ -37,7 +37,8 @@ function mathallo_preprocess_region(&$variables) {
|
||||
}
|
||||
|
||||
|
||||
function mathallo_preprocess_block__mathallo_contenu(&$variables) {
|
||||
// function mathallo_preprocess_block__mathallo_contenu(&$variables) {
|
||||
function mathallo_preprocess_block__menu_block__contenu(&$variables) {
|
||||
foreach ($variables['content']['#items'] as $key => $item) {
|
||||
parse_menu_item($variables['content']['#items'], $key);
|
||||
}
|
||||
@@ -47,14 +48,20 @@ function parse_menu_item(&$items, $key){
|
||||
if ($items[$key]['url']->getRouteName() === "entity.node.canonical") {
|
||||
$nid = $items[$key]['url']->getRouteParameters()['node'];
|
||||
$node = \Drupal\node\Entity\Node::load($nid);
|
||||
// create prefix (label) for chapitres
|
||||
if ($node->getType() === "chapitre") {
|
||||
$chapitre = $node->get('field_chapitre_num')->getValue()[0]['value'];
|
||||
$items[$key]['prefix'] = "Chapitre {$chapitre}";
|
||||
}
|
||||
// create prefix (label) for parties
|
||||
if ($node->getType() === "partie") {
|
||||
$partie = $node->get('field_partie')->getValue()[0]['value'];
|
||||
$items[$key]['prefix'] = "Partie {$partie}";
|
||||
}
|
||||
// add active attribute
|
||||
if ($items[$key]['in_active_trail']){
|
||||
$items[$key]['attributes']->offsetSet('class', 'in-active-trail');
|
||||
}
|
||||
}
|
||||
if (count($items[$key]['below']) > 0) {
|
||||
foreach ($items[$key]['below'] as $key_b => $item_b) {
|
||||
|
||||
Reference in New Issue
Block a user