You are here

function menu_position_menu_position_rule_content_type_form in Menu Position 7

Same name and namespace in other branches
  1. 6 plugins/menu_position.content_type.inc \menu_position_menu_position_rule_content_type_form()
  2. 7.2 plugins/menu_position.content_type.inc \menu_position_menu_position_rule_content_type_form()

Adds form elements for the "content type" 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.content_type.inc, line 30
Provides the "Content type" rule plugin for the Menu Position module.

Code

function menu_position_menu_position_rule_content_type_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']['content_type']) ? $form_state['#menu-position-rule']['conditions']['content_type'] : array();
  $form['conditions']['content_type'] = array(
    '#type' => 'fieldset',
    '#title' => t('Content types'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#attached' => array(
      'js' => array(
        drupal_get_path('module', 'menu_position') . '/plugins/menu_position.content_type.js',
      ),
    ),
  );
  $form['conditions']['content_type']['content_type'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Content types'),
    '#default_value' => !empty($variables['content_type']) ? $variables['content_type'] : array(),
    '#options' => node_type_get_names(),
    '#description' => t('Apply this rule only on pages that display content of the given type(s). If you select no types, there will be no type-specific limitation.'),
    '#weight' => -20,
  );

  // Add a submit handler.
  $form['#submit'][] = 'menu_position_menu_position_rule_content_type_form_submit';
}