merged materiobasemod submodule
This commit is contained in:
117
sites/all/modules/gui/materiobasemod/materio_didactique.module
Executable file
117
sites/all/modules/gui/materiobasemod/materio_didactique.module
Executable file
@@ -0,0 +1,117 @@
|
||||
<?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;
|
||||
}
|
Reference in New Issue
Block a user