1.20.x system.menu.inc | system_menu_block_form($config) |
Returns the configuration form for a menu tree.
Parameters
$config: An associated array of settings passed in by hook_block_configure(). If none are given, default configuration is assumed.
Return value
The form array. This is a form fragment and not in full Form API format.:
File
- modules/
system/ system.menu.inc, line 45
Code
function system_menu_block_form($config) {
$form['menu_name'] = array(
'#type' => 'value',
'#value' => $config['menu_name'],
);
$form['style'] = array(
'#type' => 'select',
'#title' => t('Menu style'),
'#options' => array(
'top_only' => t('Top level only'),
'dropdown' => t('Dropdown menu'),
'tree' => t('Hierarchical tree'),
),
'#default_value' => empty($config['style']) ? 'tree' : $config['style'],
);
$form['level'] = array(
'#type' => 'select',
'#title' => t('Starting level'),
'#default_value' => $config['level'],
'#options' => array(
'1' => t('1st level (primary)'),
'2' => t('2nd level (secondary)'),
'3' => t('3rd level (tertiary)'),
'4' => t('4th level'),
'5' => t('5th level'),
'6' => t('6th level'),
'7' => t('7th level'),
'8' => t('8th level'),
'9' => t('9th level'),
),
'#description' => t('The block will be visible only if the current page has its menu item at or below the level set here.'),
'#states' => array(
'visible' => array(
'select[name="block_settings[style]"]' => array('value' => 'tree'),
),
),
);
$form['depth'] = array(
'#type' => 'select',
'#title' => t('Maximum depth'),
'#default_value' => $config['depth'],
'#options' => array(
'1' => '1',
'2' => '2',
'3' => '3',
'4' => '4',
'5' => '5',
'6' => '6',
'7' => '7',
'8' => '8',
'9' => '9',
'0' => t('Unlimited'),
),
'#description' => t('The maximum depth of the menu tree from the starting level (if available).'),
'#states' => array(
'invisible' => array(
'select[name="block_settings[style]"]' => array('value' => 'top_only'),
),
),
);
$form['expand_all'] = array(
'#type' => 'checkbox',
'#title' => t('Show all menu links'),
'#default_value' => $config['expand_all'],
'#description' => t('When unchecked, only expanded or active trail menu links will be displayed.'),
'#states' => array(
'visible' => array(
'select[name="block_settings[style]"]' => array('value' => 'tree'),
),
),
);
$form['clickdown'] = array(
'#type' => 'checkbox',
'#title' => t('Use a click to open, instead of a hover'),
'#default_value' => $config['clickdown'],
'#description' => t('Menus that don\'t appear or disappear on hover can be better for usability in some cases.'),
'#states' => array(
'visible' => array(
'select[name="block_settings[style]"]' => array('value' => 'dropdown'),
),
),
);
$link = t('menu settings');
if (user_access('administer menu')) {
$link = l($link, 'admin/structure/menu/settings', array(
'attributes' => array('target' => '_blank'),
));
}
$form['toggle'] = array(
'#type' => 'checkbox',
'#title' => t('Display menu toggle button on small screens'),
'#default_value' => $config['toggle'],
'#description' => t('On devices with small screens, this option reduces the menu to a toggle button, commonly known as <a href="https://en.wikipedia.org/wiki/Hamburger_button" target="_blank"><em>hamburger button</em></a>. Clicking the icon reveals or hides the menu, saving screen space. The breakpoint for small screens can be configured in the global !menu_settings.', array(
'!menu_settings' => $link,
)),
);
return $form;
}