home is working now like the productions home page
This commit is contained in:
@@ -1,81 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Drupal\Core\Url;
|
||||
|
||||
function template_preprocess_edlp_home(&$vars){
|
||||
$view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
|
||||
// dpm($vars);
|
||||
|
||||
// render the presentation column
|
||||
$vars["presentation"] = array(
|
||||
"#type"=>"container",
|
||||
"pres"=>$view_builder->view($vars["presentation_node"], 'default'),
|
||||
"link"=> array(
|
||||
'#title' => t('Visiter la collection sonore.'),
|
||||
'#type' => 'link',
|
||||
'#url' => Url::fromRoute('<front>', [], array(
|
||||
'attributes' => array(
|
||||
'class' => ['corpus-link', 'ajax-link']
|
||||
)
|
||||
))
|
||||
)
|
||||
);
|
||||
|
||||
// render the last fil column
|
||||
$vars["last_fil"] = array(
|
||||
"#type" => "container",
|
||||
// 'fil' => $view_builder->view($vars['last_fil_node'], 'teaser'),
|
||||
'title'=> array("#markup" => "<h2 class='title'>Dernier Fil</h2>"),
|
||||
'fil' => $vars['last_fil_node'],
|
||||
// 'links' => array(
|
||||
// '#theme' => 'item_list',
|
||||
// '#items' => array(
|
||||
// 'link_all' => array(
|
||||
// '#title' => t("Voir tous les fils de l'EP."),
|
||||
// '#type' => 'link',
|
||||
// '#url' => Url::fromRoute('edlp_fils.fils', [], array(
|
||||
// 'attributes' => array(
|
||||
// 'class' => ['fils-link', 'ajax-link']
|
||||
// )
|
||||
// ))
|
||||
// ),
|
||||
// // TODO: link posdcast fils
|
||||
// 'link_podcast' => array(
|
||||
// '#title' => t("S'abonner au podcast des fils."),
|
||||
// '#type' => 'link',
|
||||
// '#url' => Url::fromRoute('<front>', [], array(
|
||||
// 'attributes' => array(
|
||||
// 'class' => ['fils-link']
|
||||
// )
|
||||
// ))
|
||||
// )
|
||||
// )
|
||||
// )
|
||||
);
|
||||
|
||||
// render the last production column
|
||||
$vars["last_production"] = array(
|
||||
'#type' => 'container',
|
||||
'prod' => $view_builder->view($vars['last_production_node'], 'teaser'),
|
||||
'link'=> array(
|
||||
'#title' => t('Voir toutes les productions.'),
|
||||
'#type' => 'link',
|
||||
'#url' => Url::fromRoute('edlp_productions.productions', [], array(
|
||||
'attributes' => array(
|
||||
'class' => ['productions-link', 'ajax-link']
|
||||
)
|
||||
))
|
||||
)
|
||||
);
|
||||
|
||||
// render the next events of agenda as list
|
||||
$agenda = array (
|
||||
'#theme' => 'item_list',
|
||||
'#items' => [],
|
||||
);
|
||||
foreach($vars['agenda_items'] as $node){
|
||||
$agenda['#items'][] = $view_builder->view($node, 'teaser');
|
||||
}
|
||||
$vars['agenda'] = render($agenda);
|
||||
|
||||
}
|
||||
@@ -17,11 +17,12 @@ function edlp_home_theme($existing, $type, $theme, $path) {
|
||||
return array(
|
||||
'edlp_home' => array(
|
||||
// 'render element' => '',
|
||||
'file' => 'edlp_home.inc',
|
||||
'file' => 'includes/edlp_home.inc',
|
||||
'variables' => array(
|
||||
'presentation_node' => NULL,
|
||||
'last_fil_node' => NULL,
|
||||
'last_production_node' => NULL,
|
||||
// 'presentation_node' => NULL,
|
||||
// 'last_fil_node' => NULL,
|
||||
// 'last_production_node' => NULL,
|
||||
'promoted_nodes' => array(),
|
||||
'agenda_items' => NULL
|
||||
),
|
||||
),
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
use Drupal\Core\Url;
|
||||
|
||||
function template_preprocess_edlp_home(&$vars){
|
||||
$view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
|
||||
// dpm($vars);
|
||||
|
||||
// render the promoted_nodes
|
||||
foreach($vars['promoted_nodes'] as $node){
|
||||
if($node->hasField('field_view_mode')){
|
||||
switch($node->get('field_view_mode')->value){
|
||||
case "1":
|
||||
$vm = "image_2_columns";
|
||||
break;
|
||||
case "2":
|
||||
$vm = "image_1_columns";
|
||||
break;
|
||||
case "3":
|
||||
$vm = "text_1_column";
|
||||
break;
|
||||
};
|
||||
}else{
|
||||
$vm = 'default';
|
||||
}
|
||||
|
||||
$vars['nodes'][] = array(
|
||||
'vm'=>$vm,
|
||||
'build'=>$view_builder->view($node, $vm)
|
||||
);
|
||||
}
|
||||
|
||||
// render the presentation column
|
||||
// $vars["presentation"] = array(
|
||||
// "#type"=>"container",
|
||||
// "pres"=>$view_builder->view($vars["presentation_node"], 'default'),
|
||||
// "link"=> array(
|
||||
// '#title' => t('Visiter la collection sonore.'),
|
||||
// '#type' => 'link',
|
||||
// '#url' => Url::fromRoute('<front>', [], array(
|
||||
// 'attributes' => array(
|
||||
// 'class' => ['corpus-link', 'ajax-link']
|
||||
// )
|
||||
// ))
|
||||
// )
|
||||
// );
|
||||
|
||||
// render the last fil column
|
||||
// $vars["last_fil"] = array(
|
||||
// "#type" => "container",
|
||||
// // 'fil' => $view_builder->view($vars['last_fil_node'], 'teaser'),
|
||||
// 'title'=> array("#markup" => "<h2 class='title'>Dernier Fil</h2>"),
|
||||
// 'fil' => $vars['last_fil_node'],
|
||||
// // 'links' => array(
|
||||
// // '#theme' => 'item_list',
|
||||
// // '#items' => array(
|
||||
// // 'link_all' => array(
|
||||
// // '#title' => t("Voir tous les fils de l'EP."),
|
||||
// // '#type' => 'link',
|
||||
// // '#url' => Url::fromRoute('edlp_fils.fils', [], array(
|
||||
// // 'attributes' => array(
|
||||
// // 'class' => ['fils-link', 'ajax-link']
|
||||
// // )
|
||||
// // ))
|
||||
// // ),
|
||||
// // // TODO: link posdcast fils
|
||||
// // 'link_podcast' => array(
|
||||
// // '#title' => t("S'abonner au podcast des fils."),
|
||||
// // '#type' => 'link',
|
||||
// // '#url' => Url::fromRoute('<front>', [], array(
|
||||
// // 'attributes' => array(
|
||||
// // 'class' => ['fils-link']
|
||||
// // )
|
||||
// // ))
|
||||
// // )
|
||||
// // )
|
||||
// // )
|
||||
// );
|
||||
|
||||
// render the last production column
|
||||
// $vars["last_production"] = array(
|
||||
// '#type' => 'container',
|
||||
// 'prod' => $view_builder->view($vars['last_production_node'], 'teaser'),
|
||||
// 'link'=> array(
|
||||
// '#title' => t('Voir toutes les productions.'),
|
||||
// '#type' => 'link',
|
||||
// '#url' => Url::fromRoute('edlp_productions.productions', [], array(
|
||||
// 'attributes' => array(
|
||||
// 'class' => ['productions-link', 'ajax-link']
|
||||
// )
|
||||
// ))
|
||||
// )
|
||||
// );
|
||||
|
||||
// render the next events of agenda as list
|
||||
$agenda = array (
|
||||
'#theme' => 'item_list',
|
||||
'#items' => [],
|
||||
);
|
||||
foreach($vars['agenda_items'] as $node){
|
||||
$agenda['#items'][] = $view_builder->view($node, 'teaser');
|
||||
}
|
||||
$vars['agenda'] = render($agenda);
|
||||
|
||||
}
|
||||
@@ -16,18 +16,36 @@ class HomeController extends ControllerBase {
|
||||
*/
|
||||
public function home() {
|
||||
|
||||
$view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
|
||||
// $view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
|
||||
|
||||
$contents = array("#theme"=>'edlp_home');
|
||||
|
||||
// presentation
|
||||
// first get static pages
|
||||
$query = \Drupal::entityQuery('node')
|
||||
->condition('status', 1)
|
||||
->condition('nid', 12242);
|
||||
// TODO: présentation nid should be a setting
|
||||
->condition('field_afficher_en_page_d_acceuil', 1)
|
||||
->condition('type', 'static');
|
||||
|
||||
$pres_nid = $query->execute();
|
||||
$contents["#presentation_node"] = entity_load('node', array_pop($pres_nid));
|
||||
$promoted_nids = $query->execute();
|
||||
$contents["#promoted_nodes"] = entity_load_multiple('node', $promoted_nids);
|
||||
|
||||
// then get production pages
|
||||
$query = \Drupal::entityQuery('node')
|
||||
->condition('status', 1)
|
||||
->condition('field_afficher_en_page_d_acceuil', 1)
|
||||
->condition('type', 'page');
|
||||
|
||||
$promoted_nids = $query->execute();
|
||||
$contents["#promoted_nodes"] += entity_load_multiple('node', $promoted_nids);
|
||||
|
||||
// presentation
|
||||
// $query = \Drupal::entityQuery('node')
|
||||
// ->condition('status', 1)
|
||||
// ->condition('nid', 12242);
|
||||
// // TODO: présentation nid should be a setting
|
||||
//
|
||||
// $pres_nid = $query->execute();
|
||||
// $contents["#presentation_node"] = entity_load('node', array_pop($pres_nid));
|
||||
|
||||
// last fil
|
||||
// $query = \Drupal::entityQuery('node')
|
||||
@@ -38,19 +56,19 @@ class HomeController extends ControllerBase {
|
||||
//
|
||||
// $fil = $query->execute();
|
||||
// $contents["#last_fil_node"] = entity_load('node', array_pop($fil));
|
||||
$contents["#last_fil_node"] = array('#markup'=>'En développement.');
|
||||
// $contents["#last_fil_node"] = array('#markup'=>'En développement.');
|
||||
|
||||
|
||||
// last production
|
||||
$query = \Drupal::entityQuery('node')
|
||||
->condition('status', 1)
|
||||
->condition('type', 'page')
|
||||
->condition('field_page_type', array('1168'), 'NOT IN')
|
||||
->sort('created', 'DESC')
|
||||
->range(0,1);
|
||||
|
||||
$prod = $query->execute();
|
||||
$contents["#last_production_node"] = entity_load('node', array_pop($prod));
|
||||
// $query = \Drupal::entityQuery('node')
|
||||
// ->condition('status', 1)
|
||||
// ->condition('type', 'page')
|
||||
// ->condition('field_page_type', array('1168'), 'NOT IN')
|
||||
// ->sort('created', 'DESC')
|
||||
// ->range(0,1);
|
||||
//
|
||||
// $prod = $query->execute();
|
||||
// $contents["#last_production_node"] = entity_load('node', array_pop($prod));
|
||||
|
||||
// agenda
|
||||
$now = new DrupalDateTime('now');
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
{{ presentation }}
|
||||
{{ last_fil }}
|
||||
{{ last_production }}
|
||||
{# presentation #}
|
||||
{# last_fil #}
|
||||
{# last_production #}
|
||||
{% for node in nodes %}
|
||||
{{ node.build }}
|
||||
{% endfor %}
|
||||
|
||||
{{ agenda }}
|
||||
|
||||
Reference in New Issue
Block a user