1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- <?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);
- }
|