123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- <?php
- /**
- * Implements hook_permission().
- */
- function materio_didactique_permission() {
- return array(
- 'view materio didactique home block' => array(
- '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().
- */
- function materio_didactique_block_info() {
- $blocks['materio_didactique_home'] = array(
- 'info' => t('Materio didactique home block'),
- 'cache' => DRUPAL_NO_CACHE
- );
- return $blocks;
- }
- /**
- * Implements hook_block_view().
- */
- function materio_didactique_block_view($delta = '') {
- $block = array();
- switch ($delta) {
- case 'materio_didactique_home':
- if(user_access('view materio didactique home block')){
- $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');
-
- if (isset($result['node'])) {
- $block['subject'] = t('Didactique home block');
- $block['content'] = theme('materio_didactique_home_block', array('items' => $result['node']));
- }
- }
- break;
-
- }
- return $block;
- }
- /**
- * Implements hook_theme().
- */
- function materio_didactique_theme($existing, $type, $theme, $path) {
- return array(
- 'materio_didactique_home_block' => array(
- 'arguments' => array('items'=>NULL),
- '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',
- )
- );
- }
- function template_preprocess_materio_didactique_home_block(&$vars){
- // dsm($vars, 'template_preprocess_materio_didactique_home_block | $vars');
- $items = array();
- foreach ($vars['items'] as $nid => $item) {
- $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;
- }
|