architecture de contenu + theming in parrallele
This commit is contained in:
@@ -29,6 +29,40 @@ function mathallo_preprocess_page(&$variables) {
|
||||
|
||||
}
|
||||
|
||||
function mathallo_preprocess_region(&$variables) {
|
||||
if (isset($variables["attributes"]['class'])) {
|
||||
$variables["attributes"]['class'] = [];
|
||||
}
|
||||
$variables["attributes"]['class'][] = "wrapper";
|
||||
}
|
||||
|
||||
|
||||
function mathallo_preprocess_block__mathallo_contenu(&$variables) {
|
||||
foreach ($variables['content']['#items'] as $key => $item) {
|
||||
parse_menu_item($variables['content']['#items'], $key);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
if ($node->getType() === "chapitre") {
|
||||
$chapitre = $node->get('field_chapitre_num')->getValue()[0]['value'];
|
||||
$items[$key]['prefix'] = "Chapitre {$chapitre}";
|
||||
}
|
||||
if ($node->getType() === "partie") {
|
||||
$partie = $node->get('field_partie')->getValue()[0]['value'];
|
||||
$items[$key]['prefix'] = "Partie {$partie}";
|
||||
}
|
||||
}
|
||||
if (count($items[$key]['below']) > 0) {
|
||||
foreach ($items[$key]['below'] as $key_b => $item_b) {
|
||||
parse_menu_item($items[$key]['below'], $key_b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_preprocess_HOOK() for node.html.twig.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user