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" => "
Dernier Fil
"),
// '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('', [], 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'=> '',
'#title' => t("Recently uploaded"),
'#suffix' => '
',
'#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'=> '',
'#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'=> '',
'#title' => t("Agenda"),
'#suffix' => '
',
'#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'=> '',
'#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'=> '',
'#title' => t("Collection"),
'#suffix' => '
',
'#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'] = render($collection);
}
if(isset($vars['production_link'])){
$production = array(
'#type'=>"container",
'title'=>array(
'#prefix'=> '',
'#title' => t("Productions"),
'#suffix' => '
',
'#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'] = render($production);
}
if(isset($vars['agenda_link'])){
$agenda = array(
'#type'=>"container",
'title'=>array(
'#prefix'=> '',
'#title' => t("Agenda"),
'#suffix' => '
',
'#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'] = render($agenda);
}
}