123456789101112131415161718192021222324252627282930 |
- <?php
- // use Drupal\Core\Url;
- function template_preprocess_edlp_corpus_articlesindex(&$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');
- if(count($vars['articles_nodes'])){
- $articles_list = array (
- '#theme' => 'item_list',
- '#items' => [],
- );
- foreach($vars['articles_nodes'] as $node){
- $articles_list['#items'][] = $view_builder->view($node, 'index');
- }
- $vars['articles'] = array(
- "#type"=>"container",
- "#attributes"=>array(
- "class"=>['articles']
- ),
- "#markup"=>"<h3>".t("Articles")."</h3>",
- "articles"=>$articles_list
- );
- }
- }
|