edlp_home.inc 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. use Drupal\Core\Url;
  3. function template_preprocess_edlp_home(&$vars){
  4. $view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
  5. // dpm($vars);
  6. // render the promoted_nodes
  7. foreach($vars['promoted_nodes'] as $node){
  8. if($node->hasField('field_view_mode')){
  9. switch($node->get('field_view_mode')->value){
  10. case "1":
  11. $vm = "image_2_columns";
  12. break;
  13. case "2":
  14. $vm = "image_1_columns";
  15. break;
  16. case "3":
  17. $vm = "text_1_column";
  18. break;
  19. };
  20. }else{
  21. $vm = 'default';
  22. }
  23. $vars['nodes'][] = array(
  24. 'vm'=>$vm,
  25. 'build'=>$view_builder->view($node, $vm)
  26. );
  27. }
  28. // render the presentation column
  29. // $vars["presentation"] = array(
  30. // "#type"=>"container",
  31. // "pres"=>$view_builder->view($vars["presentation_node"], 'default'),
  32. // "link"=> array(
  33. // '#title' => t('Visiter la collection sonore.'),
  34. // '#type' => 'link',
  35. // '#url' => Url::fromRoute('<front>', [], array(
  36. // 'attributes' => array(
  37. // 'class' => ['corpus-link', 'ajax-link']
  38. // )
  39. // ))
  40. // )
  41. // );
  42. // render the last fil column
  43. // $vars["last_fil"] = array(
  44. // "#type" => "container",
  45. // // 'fil' => $view_builder->view($vars['last_fil_node'], 'teaser'),
  46. // 'title'=> array("#markup" => "<h2 class='title'>Dernier Fil</h2>"),
  47. // 'fil' => $vars['last_fil_node'],
  48. // // 'links' => array(
  49. // // '#theme' => 'item_list',
  50. // // '#items' => array(
  51. // // 'link_all' => array(
  52. // // '#title' => t("Voir tous les fils de l'EP."),
  53. // // '#type' => 'link',
  54. // // '#url' => Url::fromRoute('edlp_fils.fils', [], array(
  55. // // 'attributes' => array(
  56. // // 'class' => ['fils-link', 'ajax-link']
  57. // // )
  58. // // ))
  59. // // ),
  60. // // // TODO: link posdcast fils
  61. // // 'link_podcast' => array(
  62. // // '#title' => t("S'abonner au podcast des fils."),
  63. // // '#type' => 'link',
  64. // // '#url' => Url::fromRoute('<front>', [], array(
  65. // // 'attributes' => array(
  66. // // 'class' => ['fils-link']
  67. // // )
  68. // // ))
  69. // // )
  70. // // )
  71. // // )
  72. // );
  73. // render the last production column
  74. // $vars["last_production"] = array(
  75. // '#type' => 'container',
  76. // 'prod' => $view_builder->view($vars['last_production_node'], 'teaser'),
  77. // 'link'=> array(
  78. // '#title' => t('Voir toutes les productions.'),
  79. // '#type' => 'link',
  80. // '#url' => Url::fromRoute('edlp_productions.productions', [], array(
  81. // 'attributes' => array(
  82. // 'class' => ['productions-link', 'ajax-link']
  83. // )
  84. // ))
  85. // )
  86. // );
  87. // render the next events of agenda as list
  88. $agenda = array (
  89. '#theme' => 'item_list',
  90. '#items' => [],
  91. );
  92. foreach($vars['agenda_items'] as $node){
  93. $agenda['#items'][] = $view_builder->view($node, 'teaser');
  94. }
  95. $vars['agenda'] = render($agenda);
  96. }