From 2f95c828e60ed82251a7d08f950e9f22c78435d3 Mon Sep 17 00:00:00 2001 From: bachy Date: Wed, 29 May 2013 20:29:27 +0200 Subject: [PATCH] didactique page Signed-off-by: bachy --- materio_didactique.module | 36 ++++++++++++++++++- materio_didactique.pages.inc | 18 +++++++++- .../materio-didactique-home-block.tpl.php | 2 +- templates/materio-didactique-page.tpl.php | 3 ++ 4 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 templates/materio-didactique-page.tpl.php diff --git a/materio_didactique.module b/materio_didactique.module index 29b72b61..5049e305 100644 --- a/materio_didactique.module +++ b/materio_didactique.module @@ -9,9 +9,30 @@ function materio_didactique_permission() { 'title' => t('view materio didactique home block'), 'description' => t(''), ), + 'access materio didactique page' => array( + 'title' => t('access materio didactique page'), + 'description' => t(''), + ), ); } +/** + * Implements hook_menu(). + */ +function materio_didactique_menu() { + + $items['whoweare'] = array( + 'title' => 'Who we are', + 'page callback' => 'materio_didactique_get_page', + // 'page arguments' => array(), + 'access arguments' => array('access materio didactique page'), + 'type' => MENU_CALLBACK, + 'file' => 'materio_didactique.pages.inc', + ); + + return $items; +} + /** * Implements hook_block_info(). */ @@ -65,6 +86,11 @@ function materio_didactique_theme($existing, $type, $theme, $path) { 'template' => 'materio-didactique-home-block', 'path' => drupal_get_path('module', 'materio_didactique').'/templates', ), + 'materio_didactique_page' => array( + 'arguments' => array('items'=>array()), + 'template' => 'materio-didactique-page', + 'path' => drupal_get_path('module', 'materio_didactique').'/templates', + ) ); } @@ -78,6 +104,14 @@ function template_preprocess_materio_didactique_home_block(&$vars){ $items[] = node_load($nid); } $vars['items'] = $items; - } +function template_preprocess_materio_didactique_page(&$vars){ + // dsm($vars, 'template_preprocess_materio_didactique_page | $vars'); + + $items = array(); + foreach ($vars['items'] as $nid => $item) { + $items[] = node_load($nid); + } + $vars['items'] = $items; +} diff --git a/materio_didactique.pages.inc b/materio_didactique.pages.inc index 5c15a99f..d245964c 100644 --- a/materio_didactique.pages.inc +++ b/materio_didactique.pages.inc @@ -1 +1,17 @@ -entityCondition('entity_type', 'node') + ->propertyCondition('status', 1) + ->entityCondition('bundle', array('didactique')) + // ->fieldCondition('field_displayed_in_home', 'value', 1) + ->fieldOrderBy('field_weight', 'value', 'ASC'); + + $result = $query->execute(); + // dsm($result, '$result'); + + return theme('materio_didactique_page', array('items' => $result['node'])); +} \ No newline at end of file diff --git a/templates/materio-didactique-home-block.tpl.php b/templates/materio-didactique-home-block.tpl.php index 1ac2f212..b2dcceba 100644 --- a/templates/materio-didactique-home-block.tpl.php +++ b/templates/materio-didactique-home-block.tpl.php @@ -1,3 +1,3 @@ + +