converted agenda output to themeable template, scss : started to implement responsivness in grid system

This commit is contained in:
Bachir Soussi Chiadmi
2018-01-16 12:39:35 +01:00
parent d29104ef4b
commit 5b77ad65fe
8 changed files with 749 additions and 469 deletions
@@ -7,3 +7,21 @@
# @Last modified by: bach
# @Last modified time: 20-12-2017
# @License: GPL-V3
/**
* Implements hook_theme().
*/
function edlp_agenda_theme($existing, $type, $theme, $path) {
// @see https://www.drupal.org/docs/8/theming/twig/create-custom-twig-templates-from-custom-module
return array(
'edlp_agenda' => array(
// 'render element' => '',
'file' => 'includes/edlp_agenda.inc',
'variables' => array(
'next_event_node' => NULL,
'coming_events_nodes' => NULL,
'past_events_nodes' => NULL
),
),
);
}
@@ -0,0 +1,67 @@
<?php
// use Drupal\Core\Url;
function template_preprocess_edlp_agenda(&$vars){
// dpm($vars);
/*
@see https://www.drupal8.ovh/index.php/en/tutoriels/339/render-a-node-or-an-entity
*/
$view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
$vars['next_event'] = array(
"#markup"=>"<h3>Prochaine Date</h3>",
"event"=>$view_builder->view($vars['next_event_node'], 'default')
);
$future_list = array (
'#theme' => 'item_list',
'#items' => [],
);
foreach($vars['coming_events_nodes'] as $node){
$future_list['#items'][] = $view_builder->view($node, 'teaser');
}
$vars['coming_events'] = array(
"#type"=>"container",
"#attributes"=>array(
"class"=>['future-events']
),
"#markup"=>"<h3>Dates à venir</h3>",
"future_events"=>$future_list
);
$past_list = array (
'#theme' => 'item_list',
'#items' => [],
);
foreach($vars['past_events_nodes'] as $node){
$past_list['#items'][] = $view_builder->view($node, 'teaser');
}
$vars['past_events'] = array(
"#type"=>"container",
"#attributes"=>array(
"class"=>['past-events']
),
"#markup"=>"<h3>Dates passées</h3>",
"past_events"=>$past_list
);
// return array(
// "#type" => "container",
// "#attributes"=>array(
// "id"=>['agenda']
// ),
// "future_past"=>array(
// "#type"=>"container",
// "#attributes"=>array(
// "class"=>['future-past-events', 'column', 'os-scroll']
// ),
// "future"=>,
// "past"=>
// )
// );
}
@@ -39,67 +39,13 @@ class AgendaController extends ControllerBase {
private function toRenderable(){
$this->query();
//
// dpm($this->future_nodes);
// dpm($this->next_event);
/*
@see https://www.drupal8.ovh/index.php/en/tutoriels/339/render-a-node-or-an-entity
*/
$view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
$future_list = array (
'#theme' => 'item_list',
'#items' => [],
);
foreach($this->future_nodes as $node){
$future_list['#items'][] = $view_builder->view($node, 'teaser');
}
$past_list = array (
'#theme' => 'item_list',
'#items' => [],
);
foreach($this->past_nodes as $node){
$past_list['#items'][] = $view_builder->view($node, 'teaser');
}
return array(
"#type" => "container",
"#attributes"=>array(
"id"=>['agenda']
),
// "#markup"=> "<h2>Agenda</h2>",
"next"=>array(
"#type"=>"container",
"#attributes"=>array(
"class"=>['next-event', 'column', 'os-scroll']
),
"#markup"=>"<h3>Prochaine Date</h3>",
"event"=>$view_builder->view($this->next_event, 'default')
),
"future_past"=>array(
"#type"=>"container",
"#attributes"=>array(
"class"=>['future-past-events', 'column', 'os-scroll']
),
"future"=>array(
"#type"=>"container",
"#attributes"=>array(
"class"=>['future-events']
),
"#markup"=>"<h3>Dates à venir</h3>",
"future_events"=>$future_list
),
"past"=>array(
"#type"=>"container",
"#attributes"=>array(
"class"=>['past-events']
),
"#markup"=>"<h3>Dates passées</h3>",
"past_events"=>$past_list
)
)
"#theme"=>'edlp_agenda',
'#next_event_node' => $this->next_event,
"#coming_events_nodes" => $this->future_nodes,
"#past_events_nodes" => $this->past_nodes,
);
}
@@ -0,0 +1,3 @@
{{ next_event }}
{{ coming_events }}
{{ past_events }}