getParameter('node'); if ($node){ $variables['attributes']['class'][] = 'node-type-' . $node->bundle(); $variables['attributes']['class'][] = 'node-id-' . $node->id(); } } // function rorschach_preprocess_node(&$variables){ // $node = &$variables['node']; // $variables['attributes']['class'][] = 'node-type-' . $node->gettype(); // if($node->gettype() == "actualite") { // $actu_type = $node->get('field_actu_type')->getString(); // $variables['attributes']['class'][] = 'actu-type-' . $actu_type; // } // if($node->gettype() == "offre_de_service") { // $type_protagoniste = $node->get('field_type_de_protagoniste')->getString(); // $variables['attributes']['class'][] = 'type-de-protagoniste-' . $type_protagoniste; // } // } function rorschach_preprocess_field(&$variables) { $node = \Drupal::routeMatch()->getParameter('node'); $field_name = &$variables['field_name']; if($node) { // if ($field_name == 'field_type_de_protagoniste'){ // $type_protagoniste = $node->get('field_type_de_protagoniste')->getString(); // $variables['attributes']['class'][] = 'type-de-protagoniste-' . $type_protagoniste; // } if ($field_name == 'block-pagetitle-2') { $depth_title = $node->get('block-pagetitle-2')->getString(); $variables['classes_array'][] = "menu-depth-" . $depth_title; } } } ////////////////////////////////////////////////// // $variables['classes_array'][] = "menu-depth-" . $depth; ////////////////////////////////////////////////// // function rorschach_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; // } // } /////////////////////////////////////////////////// /////////////////////////////////////////////////// // counter pour id // function rorschach_preprocess_field(&$variables) { // // static $counter = 0; // // $variables['counter'] = $counter++; // $variables['elements']['#paragraph']->item_id; // } // la fonction suivante ne fonctionne pas // function rorschach_preprocess_field(&$variables) { // $paragraph = &$variables['paragraph']; // $variables['attributes']['class'][] = 'paragraph-type-' . $paragraph->id(); // $hook_id = $paragraph->get('paragraph-id--')->getString(); // $variables['attributes']['class'][] = 'hook-id-' . $hook_id; // } //might be useful for if-clause: $variables['field_name'] and $variables['field_type'] // if ($paragraph && $paragraph->getEntityTypeId() == 'paragraph' . $paragraph->id() ) { //whatever logic you need goes here, e.g. something like //$variables['attributes']['data-from-parent-paragraph'] = $parentEntity->getYourStuff(); // } // function yourtheme_preprocess_field(&$variables, $hook) { // $element = $variables['element']; // $parentEntity = $element['#object']; // //might be useful for if-clause: $variables['field_name'] and $variables['field_type'] // if ($parentEntity && $parentEntity->getEntityTypeId() == 'paragraph' ) { // //whatever logic you need goes here, e.g. something like // //$variables['attributes']['data-from-parent-paragraph'] = $parentEntity->getYourStuff(); // } // } // $variables['elements']['#entity']->item_id; // function MYTHEME_preprocess_views_view_fields__view_machine_name(&$vars) { // static $counter = 0; // $vars['counter'] = $counter++; // }