Created
May 29, 2014 09:46
-
-
Save flashvnn/e7b9b6ae091732a0c530 to your computer and use it in GitHub Desktop.
Create blocks of first items of main-menu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_block_info(). | |
*/ | |
function bluecollar_helper_block_info() { | |
/* $blocks['bluecollar_resource_filter'] = array( | |
'info' => t('Resource Filter'), | |
'cache' => DRUPAL_CACHE_PER_ROLE, | |
); | |
*/ | |
$main_menu = menu_tree('main-menu'); | |
foreach (element_children($main_menu) as $key => $item) { | |
$blocks['bluecollar_submenu_' . $key] = array( | |
'info' => t('Bluecollar Submenu ' .$key), | |
'cache' => DRUPAL_CACHE_PER_ROLE, | |
); | |
} | |
return $blocks; | |
} | |
/** | |
* Implements hook_block_view(). | |
*/ | |
function bluecollar_helper_block_view($delta = '') { | |
$block = array(); | |
/* switch ($delta) { | |
case 'bluecollar_resource_filter': | |
$block['subject'] = t('Resources'); | |
$block['content'] = bluecollar_helper_resource_filter(); | |
break; | |
}*/ | |
$main_menu = menu_tree('main-menu'); | |
foreach (element_children($main_menu) as $key => $item) { | |
if ($delta == 'bluecollar_submenu_' . $key) { | |
$block['subject'] = $main_menu[$item]['#title']; | |
$block['content'] = bluecollar_helper_submenu($key); | |
} | |
} | |
return $block; | |
} | |
function bluecollar_helper_submenu($key) { | |
$main_menu = menu_tree('main-menu'); | |
$menu_keys = array_keys($main_menu); | |
if (isset($main_menu[$menu_keys[$key]]['#below'])) { | |
return drupal_render($main_menu[$menu_keys[$key]]['#below']); | |
} | |
return FALSE; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment