function _jump_menu_create_options in Better Jump Menus 8
Same name and namespace in other branches
- 6 jump_menu.module \_jump_menu_create_options()
- 7 jump_menu.module \_jump_menu_create_options()
Recursive menu to select option building.
1 call to _jump_menu_create_options()
- jump_menu in ./
jump_menu.module - Output a core menu as a select jump menu.
File
- ./
jump_menu.module, line 70 - Make use of the CTools jump menu and grabs from an existing menu. See: modules/ctools/includes/jump-menu.inc NOTE: Menu items must be checked as "expanded" for traversing to work.
Code
function _jump_menu_create_options(&$t, &$m, &$d) {
// Set the option.
foreach ($m as $item) {
// Kill non-viewable menu items.
if ($item['link']['hidden'] == 0) {
// Add depth indicators to titles.
if ($d['current'] > 1) {
$title = ' ' . str_repeat('-', $d['current'] - 1) . ' ' . $item['link']['title'];
}
else {
$title = $item['link']['title'];
}
// Add targets...
// Active and depth classes (for aggressive theming).
$classes = 'd-' . $d['current'];
// @todo Break this off once dealing with language, since it's duplicated in local tasks.
// @todo Add active trail, but beware: http://drupal.org/node/1854356
$current_path = drupal_get_normal_path(request_path());
if ($item['link']['href'] == $current_path) {
$classes .= ' active';
}
// Allow for special menu item dummy items for grouping.
if (module_exists('special_menu_items') && $item['link']['page_callback'] == 'drupal_not_found') {
// Create a dummy option using optgroups.
$t[] = array(
'title' => t($title),
'#attributes' => array(
'class' => $classes,
),
);
}
else {
// Create a normal option.
$url_options = array(
'query' => $item['link']['localized_options']['query'],
'fragment' => $item['link']['localized_options']['fragment'],
);
$t[] = array(
'value' => url($item['link']['href'], $url_options),
'title' => t($title),
'#attributes' => array(
'class' => $classes,
),
);
}
}
// Loop deeper if there is no max or we haven't reached it.
if ($item['below'] && ($d['max'] == 0 || $d['current'] < $d['max'])) {
// Drop current depth.
$d['current']++;
_jump_menu_create_options($t, $item['below'], $d);
}
}
// Raise current depth back up.
$d['current']--;
}