edlp_home.inc 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 presentation column
  7. $vars["presentation"] = array(
  8. "#type"=>"container",
  9. "pres"=>$view_builder->view($vars["presentation_node"], 'default'),
  10. "link"=> array(
  11. '#title' => t('Visiter la collection sonore.'),
  12. '#type' => 'link',
  13. '#url' => Url::fromRoute('<front>', [], array(
  14. 'attributes' => array(
  15. 'class' => ['corpus-link', 'ajax-link']
  16. )
  17. ))
  18. )
  19. );
  20. // render the last fil column
  21. $vars["last_fil"] = array(
  22. "#type" => "container",
  23. // 'fil' => $view_builder->view($vars['last_fil_node'], 'teaser'),
  24. 'title'=> array("#markup" => "<h2 class='title'>Dernier Fil</h2>"),
  25. 'fil' => $vars['last_fil_node'],
  26. // 'links' => array(
  27. // '#theme' => 'item_list',
  28. // '#items' => array(
  29. // 'link_all' => array(
  30. // '#title' => t("Voir tous les fils de l'EP."),
  31. // '#type' => 'link',
  32. // '#url' => Url::fromRoute('edlp_fils.fils', [], array(
  33. // 'attributes' => array(
  34. // 'class' => ['fils-link', 'ajax-link']
  35. // )
  36. // ))
  37. // ),
  38. // // TODO: link posdcast fils
  39. // 'link_podcast' => array(
  40. // '#title' => t("S'abonner au podcast des fils."),
  41. // '#type' => 'link',
  42. // '#url' => Url::fromRoute('<front>', [], array(
  43. // 'attributes' => array(
  44. // 'class' => ['fils-link']
  45. // )
  46. // ))
  47. // )
  48. // )
  49. // )
  50. );
  51. // render the last production column
  52. $vars["last_production"] = array(
  53. '#type' => 'container',
  54. 'prod' => $view_builder->view($vars['last_production_node'], 'teaser'),
  55. 'link'=> array(
  56. '#title' => t('Voir toutes les productions.'),
  57. '#type' => 'link',
  58. '#url' => Url::fromRoute('edlp_productions.productions', [], array(
  59. 'attributes' => array(
  60. 'class' => ['productions-link', 'ajax-link']
  61. )
  62. ))
  63. )
  64. );
  65. // render the next events of agenda as list
  66. $agenda = array (
  67. '#theme' => 'item_list',
  68. '#items' => [],
  69. );
  70. foreach($vars['agenda_items'] as $node){
  71. $agenda['#items'][] = $view_builder->view($node, 'teaser');
  72. }
  73. $vars['agenda'] = render($agenda);
  74. }