edlp_home.inc 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. 'links' => array(
  25. '#theme' => 'item_list',
  26. '#items' => array(
  27. 'link_all' => array(
  28. '#title' => t("Voir tous les fils de l'EP."),
  29. '#type' => 'link',
  30. '#url' => Url::fromRoute('edlp_fils.fils', [], array(
  31. 'attributes' => array(
  32. 'class' => ['fils-link', 'ajax-link']
  33. )
  34. ))
  35. ),
  36. // TODO: link posdcast fils
  37. 'link_podcast' => array(
  38. '#title' => t("S'abonner au podcast des fils."),
  39. '#type' => 'link',
  40. '#url' => Url::fromRoute('<front>', [], array(
  41. 'attributes' => array(
  42. 'class' => ['fils-link']
  43. )
  44. ))
  45. )
  46. )
  47. )
  48. );
  49. // render the last production column
  50. $vars["last_production"] = array(
  51. '#type' => 'container',
  52. 'prod' => $view_builder->view($vars['last_production_node'], 'teaser'),
  53. 'link'=> array(
  54. '#title' => t('Voir toutes les productions.'),
  55. '#type' => 'link',
  56. '#url' => Url::fromRoute('edlp_productions.productions', [], array(
  57. 'attributes' => array(
  58. 'class' => ['productions-link', 'ajax-link']
  59. )
  60. ))
  61. )
  62. );
  63. // render the next events of agenda as list
  64. $agenda = array (
  65. '#theme' => 'item_list',
  66. '#items' => [],
  67. );
  68. foreach($vars['agenda_items'] as $node){
  69. $agenda['#items'][] = $view_builder->view($node, 'teaser');
  70. }
  71. $vars['agenda'] = render($agenda);
  72. }