rorschach.theme 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. /*
  3. * @files
  4. * Theme Template Funtions
  5. */
  6. // use Drupal\Core\Template\Attribute;
  7. // use Drupal\Core\Link;
  8. // use Drupal\Core\Url;
  9. function rorschach_preprocess_html(&$variables) {
  10. $node = \Drupal::routeMatch()->getParameter('node');
  11. if ($node){
  12. $variables['attributes']['class'][] = 'node-type-' . $node->bundle();
  13. $variables['attributes']['class'][] = 'node-id-' . $node->id();
  14. }
  15. }
  16. function rorschach_preprocess_node(&$variables){
  17. $node = &$variables['node'];
  18. $variables['attributes']['class'][] = 'node-type-' . $node->gettype();
  19. if($node->gettype() == "book") {
  20. $book = $node->book;
  21. $variables['attributes']['class'][] = 'book-depth-' . $book['depth'];
  22. }
  23. }
  24. // function rorschach_preprocess_field(&$variables) {
  25. // $node = \Drupal::routeMatch()->getParameter('node');
  26. // // $field_name = &$variables['field_name'];
  27. // // if($node) {
  28. // // // if ($field_name == 'field_type_de_protagoniste'){
  29. // // // $type_protagoniste = $node->get('field_type_de_protagoniste')->getString();
  30. // // // $variables['attributes']['class'][] = 'type-de-protagoniste-' . $type_protagoniste;
  31. // // // }
  32. // // if ($field_name == 'block-pagetitle-2') {
  33. // // $depth_title = $node->id('block-pagetitle-2')->getString();
  34. // // $variables['attributes']['class'][] = 'menu-depth-' . $depth_title;
  35. // // }
  36. // // }
  37. // }
  38. //////////////////////////////////////////////////
  39. // $variables['classes_array'][] = "menu-depth-" . $depth;
  40. //////////////////////////////////////////////////
  41. // function rorschach_preprocess_field(&$variables){
  42. // $node = &$variables['node'];
  43. // $variables['attributes']['class'][] = 'node-type-' . $node->gettype();
  44. // if($node->gettype() == "offre_de_service") {
  45. // $type_protagoniste = $node->get('field_type_de_protagoniste')->getString();
  46. // $variables['attributes']['class'][] = 'type-de-protagoniste-' . $type_protagoniste;
  47. // }
  48. // }
  49. // function MYTHEME_preprocess_field__MYFIELD(&$variables) {
  50. // if ($variables['element']['#entity_type'] === 'node') {
  51. // $node = $variables['element']['#object'];
  52. // $nid = $node->id();
  53. // $variables['myurl'] = \Drupal::service('path.alias_manager')->getAliasByPath('/node/' . $nid);
  54. // }
  55. // }
  56. // function template_preprocess_block(&$variables) {
  57. // $node = &$variables['node'];
  58. // $variables['attributes']['class'][] = 'node-type-' . $node->gettype();
  59. // if($node->gettype() == "offre_de_service") {
  60. // $type_protagoniste = $node->get('field_type_de_protagoniste')->getString();
  61. // $variables['attributes']['class'][] = 'type-de-protagoniste-' . $type_protagoniste;
  62. // }
  63. // }
  64. ///////////////////////////////////////////////////