浏览代码

didactique page

Signed-off-by: bachy <git@g-u-i.net>
bachy 11 年之前
父节点
当前提交
2f95c828e6

+ 35 - 1
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;
+}

+ 17 - 1
materio_didactique.pages.inc

@@ -1 +1,17 @@
-<?php 
+<?php 
+
+
+function materio_didactique_get_page(){
+	$query = new EntityFieldQuery;
+	$query
+		->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']));
+}

+ 1 - 1
templates/materio-didactique-home-block.tpl.php

@@ -1,3 +1,3 @@
 <?php
 
-print render(entity_view('node', $items, 'default'));
+print render(entity_view('node', $items, 'teaser'));

+ 3 - 0
templates/materio-didactique-page.tpl.php

@@ -0,0 +1,3 @@
+<section id="didactique-page">
+	<?php print render(entity_view('node', $items, 'full')); ?>
+</section>