function _jump_menu_create_options in Better Jump Menus 7
Same name and namespace in other branches
- 8 jump_menu.module \_jump_menu_create_options()
- 6 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 76 - 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 option 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';
}
$attributes = array(
'class' => $classes,
);
// Add attribute for opening mode.
if (isset($item['link']['options']['attributes']['target'])) {
$attributes['target'] = $item['link']['options']['attributes']['target'];
}
// 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' => $attributes,
);
}
else {
// Create a normal option.
$url_options = array();
if (!empty($item['link']['localized_options']['query'])) {
$url_options['query'] = $item['link']['localized_options']['query'];
}
if (!empty($item['link']['localized_options']['fragment'])) {
$url_options['fragment'] = $item['link']['localized_options']['fragment'];
}
$t[] = array(
'value' => url($item['link']['href'], $url_options),
'title' => t($title),
'#attributes' => $attributes,
);
}
}
// 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']--;
}