Explorar o código

added last fil to edlp_home

Bachir Soussi Chiadmi %!s(int64=6) %!d(string=hai) anos
pai
achega
e0d2c6ea20

+ 5 - 2
sites/all/modules/figli/edlp_home/edlp_home.inc

@@ -6,9 +6,12 @@ function template_preprocess_edlp_home(&$vars){
   // dpm($vars);
 
   // render the presentation node
-  $vars["presentation"] = $view_builder->view($vars["presentation_node"], 'default');
+  $vars["presentation"] = array(
+    $view_builder->view($vars["presentation_node"], 'default')
+  );
 
-  // TODO: last fil
+  // render the last fil node
+  $vars["last_fil"] = $view_builder->view($vars['last_fil_node'], 'teaser');
 
   // render the last production node
   $vars["last_production"] = $view_builder->view($vars['last_production_node'], 'teaser');

+ 11 - 5
sites/all/modules/figli/edlp_home/src/Controller/HomeController.php

@@ -28,17 +28,23 @@ class HomeController extends ControllerBase {
     $pres_nid = $query->execute();
     $contents["#presentation_node"] = entity_load('node', array_pop($pres_nid));
 
+    // last fil
+    $query = \Drupal::entityQuery('node')
+      ->condition('status', 1)
+      ->condition('type', 'fil')
+      ->sort('created', 'DESC')
+      ->range(0,1);
 
-    // TODO: last fil
-    // $contents["#last_fil_node"] = "Last Fil";
+    $fil = $query->execute();
+    $contents["#last_fil_node"] = entity_load('node', array_pop($fil));
 
-    // TODO: last production
+    // last production
     $query = \Drupal::entityQuery('node')
       ->condition('status', 1)
       ->condition('type', 'page')
       ->condition('field_page_type', array('1168'), 'NOT IN')
-      ->range(0,1)
-      ->sort('created', 'DESC');
+      ->sort('created', 'DESC')
+      ->range(0,1);
 
     $prod = $query->execute();
     $contents["#last_production_node"] = entity_load('node', array_pop($prod));