didactique
Signed-off-by: bachy <git@g-u-i.net>
This commit is contained in:
parent
ef943eba75
commit
8e956c857b
29
materio_didactique.info
Normal file
29
materio_didactique.info
Normal file
@ -0,0 +1,29 @@
|
||||
name = Materio Didactique
|
||||
description = "Materio Didactique module"
|
||||
|
||||
; Core version (required)
|
||||
core = 7.x
|
||||
|
||||
; Package name (see http://drupal.org/node/542202 for a list of names)
|
||||
package = Materio
|
||||
|
||||
; PHP version requirement (optional)
|
||||
; php = 5.2
|
||||
|
||||
; Loadable code files
|
||||
;files[] = materio_didactique.theme.inc
|
||||
;files[] = materio_didactique.forms.inc
|
||||
files[] = materio_didactique.pages.inc
|
||||
;files[] = materio_didactique.admin.inc
|
||||
files[] = materio_didactique.module
|
||||
|
||||
; Module dependencies
|
||||
;dependencies[] = taxonomy
|
||||
;dependencies[] = search_api
|
||||
;dependencies[] = search_api_solr
|
||||
|
||||
; Configuration page
|
||||
; configure = admin/config/materiobasemod
|
||||
|
||||
; For further information about configuration options, see
|
||||
; - http://drupal.org/node/542202
|
83
materio_didactique.module
Normal file
83
materio_didactique.module
Normal file
@ -0,0 +1,83 @@
|
||||
<?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(''),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
|
1
materio_didactique.pages.inc
Normal file
1
materio_didactique.pages.inc
Normal file
@ -0,0 +1 @@
|
||||
<?php
|
3
templates/materio-didactique-home-block.tpl.php
Normal file
3
templates/materio-didactique-home-block.tpl.php
Normal file
@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
print render(entity_view('node', $items, 'default'));
|
Loading…
x
Reference in New Issue
Block a user