123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218 |
- <?php
- use Drupal\Core\Url;
- function template_preprocess_edlp_home(&$vars){
- $node_view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
- // $term_view_builder = \Drupal::entityTypeManager()->getViewBuilder('taxonomy_term');
- // dpm($vars);
- // render the promoted_statics and promoted_prods
- $promoteds = ['statics', 'prods'];
- foreach ($promoteds as $index => $p) {
- $vars['nodes_' . $p] = array();
- if(isset($vars['promoted_' . $p])){
- foreach($vars['promoted_' . $p] 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_' . $p][] = array(
- 'vm'=>$vm,
- 'build'=>$node_view_builder->view($node, $vm)
- );
- }
- }
- }
- // render the last fil column
- // $vars["last_fil"] = array(
- // "#type" => "container",
- // // 'fil' => $node_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 lasts documents of collection as list
- if(isset($vars['lastdocs_items'])){
- $lastdocs_url = Url::fromRoute('edlp_corpus.lastdocs');
- $lastdocs = array(
- '#type'=>"container",
- 'title'=>array(
- '#prefix'=> '<h3>',
- '#title' => t("Recently uploaded"),
- '#suffix' => '</h3>',
- '#type' => 'link',
- '#url' => $lastdocs_url,
- '#options'=>array(
- 'attributes' => array(
- 'data-drupal-link-system-path' => $lastdocs_url->getInternalPath(),
- 'class' => array('ajax-link'),
- )
- )
- ),
- 'list'=> array(
- '#theme' => 'item_list',
- '#items' => [],
- ),
- 'seeall'=>array(
- '#type' => 'link',
- '#prefix'=> '<nav>',
- '#title' => t("See all"),
- '#suffix'=> '</nav>',
- '#url' => $lastdocs_url,
- '#options'=>array(
- 'attributes' => array(
- 'data-drupal-link-system-path' => $lastdocs_url->getInternalPath(),
- 'class' => array('ajax-link'),
- )
- )
- ),
- );
- foreach($vars['lastdocs_items'] as $node){
- $lastdocs['list']['#items'][] = $node_view_builder->view($node, 'search_index');
- }
- $vars['lastdocs'] = \Drupal::service('renderer')->render($lastdocs);
- }
- // render the next events of agenda as list
- if(isset($vars['agenda_items'])){
- $agenda_url = Url::fromRoute('edlp_agenda.agenda');
- $agenda = array(
- '#type'=>"container",
- 'title'=>array(
- '#prefix'=> '<h3>',
- '#title' => t("Agenda"),
- '#suffix' => '</h3>',
- '#type' => 'link',
- '#url' => $agenda_url,
- '#options'=>array(
- 'attributes' => array(
- 'data-drupal-link-system-path' => $agenda_url->getInternalPath(),
- 'class' => array('ajax-link'),
- )
- )
- ),
- 'list'=> array(
- '#theme' => 'item_list',
- '#items' => [],
- ),
- 'seeall'=>array(
- '#type' => 'link',
- '#prefix'=> '<nav>',
- '#title' => t("See all"),
- '#suffix'=> '</nav>',
- '#url' => $agenda_url,
- '#options'=>array(
- 'attributes' => array(
- 'data-drupal-link-system-path' => $agenda_url->getInternalPath(),
- 'class' => array('ajax-link'),
- )
- )
- ),
- );
- foreach($vars['agenda_items'] as $node){
- $agenda['list']['#items'][] = $node_view_builder->view($node, 'teaser');
- }
- $vars['agenda'] = \Drupal::service('renderer')->render($agenda);
- }
- if(isset($vars['collection_link'])){
- $collection = array(
- '#type'=>"container",
- 'title'=>array(
- '#prefix'=> '<h3>',
- '#title' => t("Collection"),
- '#suffix' => '</h3>',
- '#type' => 'link',
- '#url' => $vars['collection_link']['url'],
- '#options'=>array(
- 'attributes' => array(
- 'data-drupal-link-system-path' => $vars['collection_link']['internal_path'],
- 'class' => array('ajax-link'),
- )
- )
- )
- );
- $vars['collection_link_rendered'] = \Drupal::service('renderer')->render($collection);
- }
- if(isset($vars['production_link'])){
- $production = array(
- '#type'=>"container",
- 'title'=>array(
- '#prefix'=> '<h3>',
- '#title' => t("Productions"),
- '#suffix' => '</h3>',
- '#type' => 'link',
- '#url' => $vars['production_link']['url'],
- '#options'=>array(
- 'attributes' => array(
- 'data-drupal-link-system-path' => $vars['production_link']['internal_path'],
- 'class' => array('ajax-link'),
- )
- )
- )
- );
- $vars['production_link_rendered'] = \Drupal::service('renderer')->render($production);
- }
- if(isset($vars['agenda_link'])){
- $agenda = array(
- '#type'=>"container",
- 'title'=>array(
- '#prefix'=> '<h3>',
- '#title' => t("Agenda"),
- '#suffix' => '</h3>',
- '#type' => 'link',
- '#url' => $vars['agenda_link']['url'],
- '#options'=>array(
- 'attributes' => array(
- 'data-drupal-link-system-path' => $vars['agenda_link']['internal_path'],
- 'class' => array('ajax-link'),
- )
- )
- )
- );
- $vars['agenda_link_rendered'] = \Drupal::service('renderer')->render($agenda);
- }
- }
|