| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 | <?phpuse 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_nodes  $vars['nodes'] = array();  if(isset($vars['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'=>$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'] = 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'] = 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'] = render($collection);  }}
 |