id and color / type protagoniste

This commit is contained in:
2022-01-21 13:36:49 +01:00
parent c565e1a188
commit 7add543d1c
8 changed files with 224 additions and 46 deletions
+41 -1
View File
@@ -15,7 +15,6 @@ function eql_preprocess_html(&$variables) {
$variables['attributes']['class'][] = 'node-type-' . $node->bundle();
$variables['attributes']['class'][] = 'node-id-' . $node->id();
}
}
@@ -33,6 +32,47 @@ function eql_preprocess_node(&$variables){
}
/**
* Implements hook_preprocess_field().
*/
function eql_preprocess_field(&$variables) {
$node = \Drupal::routeMatch()->getParameter('node');
if($node) {
$type_protagoniste = $node->get('field_type_de_protagoniste')->getString();
$variables['attributes']['class'][] = 'type-de-protagoniste-' . $type_protagoniste;
}
}
// function eql_preprocess_field(&$variables){
// $node = &$variables['node'];
// $variables['attributes']['class'][] = 'node-type-' . $node->gettype();
// if($node->gettype() == "offre_de_service") {
// $type_protagoniste = $node->get('field_type_de_protagoniste')->getString();
// $variables['attributes']['class'][] = 'type-de-protagoniste-' . $type_protagoniste;
// }
// }
// function MYTHEME_preprocess_field__MYFIELD(&$variables) {
// if ($variables['element']['#entity_type'] === 'node') {
// $node = $variables['element']['#object'];
// $nid = $node->id();
// $variables['myurl'] = \Drupal::service('path.alias_manager')->getAliasByPath('/node/' . $nid);
// }
// }
// function template_preprocess_block(&$variables) {
// $node = &$variables['node'];
// $variables['attributes']['class'][] = 'node-type-' . $node->gettype();
// if($node->gettype() == "offre_de_service") {
// $type_protagoniste = $node->get('field_type_de_protagoniste')->getString();
// $variables['attributes']['class'][] = 'type-de-protagoniste-' . $type_protagoniste;
// }
// }
///////////////////////////////////////////////////