diff --git a/sites/all/modules/figli/edlp_productions/edlp_productions.module b/sites/all/modules/figli/edlp_productions/edlp_productions.module
index 55cf52bb2..421840449 100644
--- a/sites/all/modules/figli/edlp_productions/edlp_productions.module
+++ b/sites/all/modules/figli/edlp_productions/edlp_productions.module
@@ -6,3 +6,19 @@
# @Last modified by: bach
# @Last modified time: 20-12-2017
# @License: GPL-V3
+
+/**
+ * Implements hook_theme().
+ */
+function edlp_productions_theme($existing, $type, $theme, $path) {
+ // @see https://www.drupal.org/docs/8/theming/twig/create-custom-twig-templates-from-custom-module
+ return array(
+ 'edlp_productions' => array(
+ // 'render element' => '',
+ 'file' => 'includes/edlp_productions.inc',
+ 'variables' => array(
+ 'hello' => NULL,
+ ),
+ ),
+ );
+}
diff --git a/sites/all/modules/figli/edlp_productions/includes/edlp_productions.inc b/sites/all/modules/figli/edlp_productions/includes/edlp_productions.inc
new file mode 100644
index 000000000..459262d81
--- /dev/null
+++ b/sites/all/modules/figli/edlp_productions/includes/edlp_productions.inc
@@ -0,0 +1,18 @@
+getViewBuilder('node');
+
+ // $vars['next_event'] = array(
+ // "#markup"=>"
Prochaine Date
",
+ // "event"=>$view_builder->view($vars['next_event_node'], 'default')
+ // );
+
+
+}
diff --git a/sites/all/modules/figli/edlp_productions/src/Controller/ProductionsController.php b/sites/all/modules/figli/edlp_productions/src/Controller/ProductionsController.php
index 12c0e8125..7dcaa48e5 100644
--- a/sites/all/modules/figli/edlp_productions/src/Controller/ProductionsController.php
+++ b/sites/all/modules/figli/edlp_productions/src/Controller/ProductionsController.php
@@ -3,21 +3,67 @@
namespace Drupal\edlp_productions\Controller;
use Drupal\Core\Controller\ControllerBase;
-// use Drupal\Core\Datetime\DrupalDateTime;
+use Drupal\menu_link_content\Entity\MenuLinkContent;
use Symfony\Component\HttpFoundation\JsonResponse;
class ProductionsController extends ControllerBase {
+// TODO: generate the menu, how ?
+
+ private function query() {
+ // TODO: get the production menu
+ // @see https://api.drupal.org/api/drupal/core%21modules%21menu_ui%21menu_ui.module/8.6.x
+ // @see https://drupal.stackexchange.com/questions/200893/get-menu-link-page-settings-from-view-configuration
+ $menu_name = 'productions';
+
+ $query = \Drupal::entityQuery('menu_link_content')
+ ->condition('menu_name', $menu_name)
+ ->condition('enabled', 1)
+ ->sort('weight', 'ASC');
+
+ $result = $query->execute();
+ // dpm($result);
+
+ foreach ($result as $id) {
+ $menu_link = MenuLinkContent::load($id);
+ // dpm($menu_link->getParentId());
+ if($menu_link->getParentId() === ""){
+ dpm($menu_link->getTitle());
+ $path = $menu_link->getUrlObject()->getInternalPath();
+ preg_match('/^node\/(\d+)$/', $path, $m);
+ dpm($m[1]);
+ }
+ }
+
+ // TODO: loop through first level
+ // TODO: load nodes
+ // TODO: create items
+ // TODO: apply right display
+
+ }
+
+
+ private function toRenderable(){
+ $this->query();
+ // dpm($this->future_nodes);
+
+ // TODO: add localtasks to each nodes : https://api.drupal.org/api/drupal/core%21includes%21menu.inc/function/menu_primary_local_tasks/8.2.x
+
+ return array(
+ "#theme"=>'edlp_productions',
+ "#hello"=>'Hello',
+ );
+
+ }
+
/**
* Display productions as a page.
*
* @return renderable array
*/
public function productions() {
- return array(
- "#markup"=>"Edlp Productions"
- );
+ return $this->toRenderable();
}
/**
@@ -28,9 +74,7 @@ class ProductionsController extends ControllerBase {
public function productionsjson() {
$response = new JsonResponse();
- $renderable = array(
- "#markup"=>"Edlp Productions"
- );
+ $renderable = $this->toRenderable();
$rendered = render($renderable);
$response->setData([
diff --git a/sites/all/modules/figli/edlp_productions/templates/edlp-productions.html.twig b/sites/all/modules/figli/edlp_productions/templates/edlp-productions.html.twig
new file mode 100644
index 000000000..8fe25f99b
--- /dev/null
+++ b/sites/all/modules/figli/edlp_productions/templates/edlp-productions.html.twig
@@ -0,0 +1 @@
+{{ hello }}
diff --git a/sites/all/themes/custom/edlptheme/assets/dist/scripts/main.min.js b/sites/all/themes/custom/edlptheme/assets/dist/scripts/main.min.js
index 612a9d3d7..570a0ddf9 100644
--- a/sites/all/themes/custom/edlptheme/assets/dist/scripts/main.min.js
+++ b/sites/all/themes/custom/edlptheme/assets/dist/scripts/main.min.js
@@ -88,8 +88,7 @@ edlp_vars = {
return false;
}
- // TODO: drupal settings not defined on NOT front page
- var path = window.location.origin + drupalSettings.basepath + sys_path +'/ajax';
+ var path = window.location.origin + drupalSettings.path.baseUrl + sys_path +'/ajax';
closeAllModals();
_$body.addClass('ajax-loading');
$link.addClass('ajax-loading');
@@ -104,7 +103,13 @@ edlp_vars = {
console.log('ajax link loaded : data', data);
_$content_container.html(data.rendered);
_$body.removeClass('ajax-loading');
- _$body.removeClass().addClass('path-'+sys_path);
+ // add body class for currently loaded content
+ _$body.removeClass().addClass('path-'+sys_path.replace(/\//g, '-'));
+ // id node add a generic path-node class to body
+ m = sys_path.match(/^\/?(edlp\/node\/\d+)$/g);
+ if(m){
+ _$body.addClass('path-edlp-node');
+ }
_$ajaxLinks.removeClass('is-active');
$link.removeClass('ajax-loading').addClass('is-active');
initScrollbars();
diff --git a/sites/all/themes/custom/edlptheme/assets/scripts/main.js b/sites/all/themes/custom/edlptheme/assets/scripts/main.js
index 61cb2b1d0..c26745810 100644
--- a/sites/all/themes/custom/edlptheme/assets/scripts/main.js
+++ b/sites/all/themes/custom/edlptheme/assets/scripts/main.js
@@ -65,8 +65,7 @@
return false;
}
- // TODO: drupal settings not defined on NOT front page
- var path = window.location.origin + drupalSettings.basepath + sys_path +'/ajax';
+ var path = window.location.origin + drupalSettings.path.baseUrl + sys_path +'/ajax';
closeAllModals();
_$body.addClass('ajax-loading');
$link.addClass('ajax-loading');
@@ -81,7 +80,13 @@
console.log('ajax link loaded : data', data);
_$content_container.html(data.rendered);
_$body.removeClass('ajax-loading');
- _$body.removeClass().addClass('path-'+sys_path);
+ // add body class for currently loaded content
+ _$body.removeClass().addClass('path-'+sys_path.replace(/\//g, '-'));
+ // id node add a generic path-node class to body
+ m = sys_path.match(/^\/?(edlp\/node\/\d+)$/g);
+ if(m){
+ _$body.addClass('path-edlp-node');
+ }
_$ajaxLinks.removeClass('is-active');
$link.removeClass('ajax-loading').addClass('is-active');
initScrollbars();
diff --git a/sites/all/themes/custom/edlptheme/edlptheme.libraries.yml b/sites/all/themes/custom/edlptheme/edlptheme.libraries.yml
index c6c7b905a..cfeed9da2 100644
--- a/sites/all/themes/custom/edlptheme/edlptheme.libraries.yml
+++ b/sites/all/themes/custom/edlptheme/edlptheme.libraries.yml
@@ -14,6 +14,7 @@ global-js:
assets/dist/bower/jquery.overlayScrollbars.min.js: { scope: footer }
assets/dist/scripts/main.min.js: { scope: footer }
dependencies:
+ - core/drupal
- core/matchmedia
- core/matchmedia.addListener
- core/jquery