added custom layout to panles, created thematique anchor links menu
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
name = Clameurs Mod
|
||||
description = module for clameurs website
|
||||
core = 7.x
|
||||
package = "Clameurs"
|
||||
dependencies[] = panels
|
||||
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
|
||||
// function clameursmod_panels_pre_render($panel, &$renderer){
|
||||
// dsm($panel, 'panel');
|
||||
// dsm($renderer, 'renderer');
|
||||
//
|
||||
// $node_ctx = $render->display['context'][0]['data'];
|
||||
// dsm($node_ctx, 'node_ctx');
|
||||
//
|
||||
// }
|
||||
|
||||
/**
|
||||
* Implements hook_block_info().
|
||||
*/
|
||||
function clameursmod_block_info() {
|
||||
$blocks['thematiques-anchor-links'] = array(
|
||||
'info' => t('Clameurs thematique anchor links'),
|
||||
'cache' => DRUPAL_NO_CACHE
|
||||
);
|
||||
|
||||
return $blocks;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implements hook_block_view().
|
||||
*/
|
||||
function clameursmod_block_view($delta = '') {
|
||||
$block = array();
|
||||
|
||||
switch ($delta) {
|
||||
case 'thematiques-anchor-links':
|
||||
$block['subject'] = t('Thématique menu');
|
||||
$block['content'] = _clameursmod_thematiques_anchor_links();
|
||||
break;
|
||||
}
|
||||
return $block;
|
||||
}
|
||||
|
||||
function _clameursmod_thematiques_anchor_links(){
|
||||
$query = new EntityFieldQuery();
|
||||
$query
|
||||
->entityCondition('entity_type', 'node')
|
||||
->entityCondition('bundle', 'thematique')
|
||||
->propertyCondition('status', 1);
|
||||
// ->propertyOrderBy('created', 'DESC');
|
||||
|
||||
$result = $query->execute();
|
||||
$nids = array_keys($result['node']);
|
||||
|
||||
$nodes = [];
|
||||
foreach ($nids as $nid) {
|
||||
$node = node_load($nid);
|
||||
$alias = drupal_get_path_alias('node/'.$nid);
|
||||
// TODO: get the workflow state ID
|
||||
$nodes[$nid] = array(
|
||||
"alias"=>$alias,
|
||||
"title"=>$node->title
|
||||
);
|
||||
}
|
||||
return theme('thematiques_anchor_links', array("items"=>$nodes));
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_theme().
|
||||
*/
|
||||
function clameursmod_theme($existing, $type, $theme, $path) {
|
||||
return array(
|
||||
'thematiques_anchor_links' => array(
|
||||
'render element' => 'element'
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
function theme_thematiques_anchor_links($vars){
|
||||
$list = array(
|
||||
'items'=>array(),
|
||||
'type'=>'ul',
|
||||
'attributes'=>array(
|
||||
"class"=>array("thematique-anchor-links")
|
||||
)
|
||||
);
|
||||
|
||||
foreach ($vars["items"] as $nid => $val) {
|
||||
// TODO: display the workflow state ID
|
||||
$options = array(
|
||||
"class"=>array("anchor"),
|
||||
"fragment"=>$val['alias']
|
||||
);
|
||||
$list['items'][] = l($val['title'], '' , $options);
|
||||
}
|
||||
|
||||
return theme('item_list', $list);
|
||||
}
|
||||
Reference in New Issue
Block a user