edlp_corpus_articlesindex.inc 753 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. // use Drupal\Core\Url;
  3. function template_preprocess_edlp_corpus_articlesindex(&$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(count($vars['articles_nodes'])){
  10. $articles_list = array (
  11. '#theme' => 'item_list',
  12. '#items' => [],
  13. );
  14. foreach($vars['articles_nodes'] as $node){
  15. $articles_list['#items'][] = $view_builder->view($node, 'index');
  16. }
  17. $vars['articles'] = array(
  18. "#type"=>"container",
  19. "#attributes"=>array(
  20. "class"=>['articles']
  21. ),
  22. "#markup"=>"<h3>".t("Articles")."</h3>",
  23. "articles"=>$articles_list
  24. );
  25. }
  26. }