created lastdocs home block and corresponfing page
This commit is contained in:
@@ -23,6 +23,7 @@ function edlp_home_theme($existing, $type, $theme, $path) {
|
||||
// 'last_fil_node' => NULL,
|
||||
// 'last_production_node' => NULL,
|
||||
'promoted_nodes' => array(),
|
||||
'lastdocs_items' => NULL,
|
||||
'agenda_items' => NULL,
|
||||
'entrees_items' => NULL,
|
||||
),
|
||||
|
||||
@@ -93,6 +93,34 @@ function template_preprocess_edlp_home(&$vars){
|
||||
// )
|
||||
// );
|
||||
|
||||
|
||||
// render the lasts documents of collection as list
|
||||
$lastdocs_url = Url::fromRoute('edlp_corpus.lastdocs');
|
||||
$lastdocs = array(
|
||||
'#type'=>"container",
|
||||
'title'=>array(
|
||||
'#prefix'=> '<h3>',
|
||||
'#title' => t("Last documents"),
|
||||
'#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' => [],
|
||||
),
|
||||
);
|
||||
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
|
||||
$agenda_url = Url::fromRoute('edlp_agenda.agenda');
|
||||
$agenda = array(
|
||||
|
||||
@@ -72,6 +72,17 @@ class HomeController extends ControllerBase {
|
||||
// $prod = $query->execute();
|
||||
// $contents["#last_production_node"] = entity_load('node', array_pop($prod));
|
||||
|
||||
// last documents
|
||||
$query = \Drupal::entityQuery('node')
|
||||
->condition('status', 1)
|
||||
->condition('type', 'enregistrement')
|
||||
->sort('created', 'DESC')
|
||||
->range(0,10);
|
||||
|
||||
$lastdocs = $query->execute();
|
||||
$contents["#lastdocs_items"] = entity_load_multiple('node', $lastdocs);
|
||||
// dsm($contents["#lastdocs_items"], "#lastdocs_items");
|
||||
|
||||
// agenda
|
||||
$now = new DrupalDateTime('now');
|
||||
$now->setTimezone(new \DateTimeZone(DATETIME_STORAGE_TIMEZONE));
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
{{ node.build }}
|
||||
{% endfor %}
|
||||
|
||||
{{ lastdocs }}
|
||||
|
||||
{{ agenda }}
|
||||
|
||||
{% if entrees %}
|
||||
|
||||
Reference in New Issue
Block a user