edlp_agenda.inc 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. // use Drupal\Core\Url;
  3. function template_preprocess_edlp_agenda(&$vars){
  4. // dpm($vars);
  5. /*
  6. @see https://www.drupal8.ovh/index.php/en/tutoriels/339/render-a-node-or-an-entity
  7. */
  8. $view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
  9. // if(isset($vars['next_event_node'])){
  10. // $vars['next_event'] = array(
  11. // "#markup"=>"<h3>Prochaine Date</h3>",
  12. // "event"=>$view_builder->view($vars['next_event_node'], 'default')
  13. // );
  14. // }
  15. if(count($vars['coming_events_nodes'])){
  16. $future_list = array (
  17. '#theme' => 'item_list',
  18. '#items' => [],
  19. );
  20. foreach($vars['coming_events_nodes'] as $node){
  21. $future_list['#items'][] = $view_builder->view($node, 'teaser');
  22. }
  23. $vars['coming_events'] = array(
  24. "#type"=>"container",
  25. "#attributes"=>array(
  26. "class"=>['future-events']
  27. ),
  28. "#markup"=>"<h3>".t("Upcoming Events")."</h3>",
  29. "future_events"=>$future_list
  30. );
  31. }
  32. $past_list = array (
  33. '#theme' => 'item_list',
  34. '#items' => [],
  35. );
  36. foreach($vars['past_events_nodes'] as $node){
  37. $past_list['#items'][] = $view_builder->view($node, 'teaser');
  38. }
  39. $vars['past_events'] = array(
  40. "#type"=>"container",
  41. "#attributes"=>array(
  42. "class"=>['past-events']
  43. ),
  44. "#markup"=>"<h3>".t("Past Events")."</h3>",
  45. "past_events"=>$past_list
  46. );
  47. // return array(
  48. // "#type" => "container",
  49. // "#attributes"=>array(
  50. // "id"=>['agenda']
  51. // ),
  52. // "future_past"=>array(
  53. // "#type"=>"container",
  54. // "#attributes"=>array(
  55. // "class"=>['future-past-events', 'column', 'os-scroll']
  56. // ),
  57. // "future"=>,
  58. // "past"=>
  59. // )
  60. // );
  61. }