function menu_position_menu_position_rule_language_form in Menu Position 7.2
Same name and namespace in other branches
- 7 plugins/menu_position.language.inc \menu_position_menu_position_rule_language_form()
Adds form elements for the "language" plugin to the rule configuration form.
Parameters
$form: A reference to the "add/edit rule" form array. New form elements should be added directly to this array.
$form_state: A reference to the current form state.
File
- plugins/
menu_position.language.inc, line 30 - Provides the "Language" rule plugin for the Menu Position module.
Code
function menu_position_menu_position_rule_language_form(&$form, &$form_state) {
// If this is an existing rule, load the variables stored in the rule for this plugin.
$variables = !empty($form_state['#menu-position-rule']['conditions']['language']) ? $form_state['#menu-position-rule']['conditions']['language'] : array();
$form['conditions']['language'] = array(
'#type' => 'fieldset',
'#title' => t('Language'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#attached' => array(
'js' => array(
drupal_get_path('module', 'menu_position') . '/plugins/menu_position.language.js',
),
),
);
$form['conditions']['language']['language'] = array(
'#type' => 'select',
'#title' => t('Language'),
'#options' => array(
'' => t('Any language'),
) + locale_language_list(),
'#default_value' => !empty($variables['language']) ? $variables['language'] : '',
'#description' => t("Apply this rule only when the language matches the current page's language."),
'#weight' => -20,
);
// Add a submit handler.
$form['#submit'][] = 'menu_position_menu_position_rule_language_form_submit';
}