'', // 'page callback' => '', // 'page arguments' => array(), // 'access arguments' => array(''), // 'type' => , // 'file' => , // ); // // return $items; // } /** * Implements hook_entity_info_alter(). */ function clameursmod_entity_info_alter(&$entity_info) { $entity_info['node']['view modes']['accueil'] = array( 'label' => t('Accueil'), 'custom settings' => TRUE, ); } /** * Implements hook_block_info(). */ function clameursmod_block_info() { $blocks['thematiques'] = array( 'info' => t('Clameurs thematiques'), 'cache' => DRUPAL_NO_CACHE ); $blocks['thematiques-anchor-links'] = array( 'info' => t('Clameurs thematiques anchor links'), 'cache' => DRUPAL_NO_CACHE ); return $blocks; } /** * Implements hook_block_view(). */ function clameursmod_block_view($delta = '') { $block = array(); switch ($delta) { case 'thematiques': $block['subject'] = t('Thématiques'); $block['content'] = _clameursmod_thematiques(); break; case 'thematiques-anchor-links': $block['subject'] = t('Thématiques menu'); $block['content'] = _clameursmod_thematiques_anchor_links(); break; } return $block; } /** * Implements hook_theme(). */ function clameursmod_theme($existing, $type, $theme, $path) { return array( 'thematiques' => array( 'render element' => 'element' ), 'thematiques_anchor_links' => array( 'render element' => 'element' ), ); } // ________ __ _ // /_ __/ /_ ___ ____ ___ ____ _/ /_(_)___ ___ _____ _____ // / / / __ \/ _ \/ __ `__ \/ __ `/ __/ / __ `/ / / / _ \/ ___/ // / / / / / / __/ / / / / / /_/ / /_/ / /_/ / /_/ / __(__ ) // /_/ /_/ /_/\___/_/ /_/ /_/\__,_/\__/_/\__, /\__,_/\___/____/ // /_/ function _clameursmod_thematiques(){ $query = new EntityFieldQuery(); $query ->entityCondition('entity_type', 'node') ->entityCondition('bundle', 'thematique') ->propertyCondition('status', 1) ->fieldOrderBy('field_poid', 'value', 'ASC'); $result = $query->execute(); // dsm($result['node'], "result"); $nids = array_keys($result['node']); $nodes = array(); foreach ($nids as $nid) { $nodes[] = node_load($nid); } return theme('thematiques', array("items"=>$nodes)); } function theme_thematiques($vars){ $nodes = $vars['items']; $view_mode = "accueil"; $entity_view = entity_view('node', $nodes, $view_mode); return render($entity_view); } // ___ __ // / | ____ _____/ /_ ____ __________ // / /| | / __ \/ ___/ __ \/ __ \/ ___/ ___/ // / ___ |/ / / / /__/ / / / /_/ / / (__ ) // /_/ |_/_/ /_/\___/_/ /_/\____/_/ /____/ function _clameursmod_thematiques_anchor_links(){ $query = new EntityFieldQuery(); $query ->entityCondition('entity_type', 'node') ->entityCondition('bundle', 'thematique') ->propertyCondition('status', 1) ->fieldOrderBy('field_poid', 'value', 'ASC'); $result = $query->execute(); $nids = array_keys($result['node']); $nodes = []; foreach ($nids as $nid) { $node = node_load($nid); // dsm($node); $alias = drupal_get_path_alias('node/'.$nid); // get the workflow state ID $current_state = workflow_state_load_single($node->workflow); // dsm($current_state, 'current_state'); // $workflow = $current_state->getWorkflow(); // dsm($workflow, "workflow"); $scheduled_transitions = WorkflowScheduledTransition::load('node', $nid, NULL, 1); $transition = false; if(count($scheduled_transitions)){ // dsm($scheduled_transitions, "scheduled_transitions"); $transition = $scheduled_transitions[0]; } $nodes[$nid] = array( "alias"=>$alias, "title"=>$node->title, "wf_sid"=>$node->workflow, "wf_stamp"=> $transition ? $transition->scheduled : false, "wf_state"=>$current_state->getName(), ); } return theme('thematiques_anchor_links', array("items"=>$nodes)); } function theme_thematiques_anchor_links($vars){ $list = array( 'items'=>array(), 'type'=>'ul', 'attributes'=>array( "class"=>array("thematique-anchor-links") ) ); $i=0; foreach ($vars["items"] as $nid => $val) { // TODO: display the workflow state ID $options = array( "attributes"=>array( "class"=>array("anchor","pos-".$i, $val['wf_state'], 'node-'.$nid), ), "fragment"=>$val['alias'], "html"=>true, ); $content = $val['title']; if($val["wf_stamp"]){ $content .= "" . format_date($val["wf_stamp"], 'custom', "d M Y") . ""; } $list['items'][] = l($content, '' , $options); $i++; } return theme('item_list', $list); }