You are here

function submenutree_form_node_form_alter in Submenu Tree 7

Implements hook_form_BASE_ID_alter().

File

./submenutree.module, line 43
Submenu Tree

Code

function submenutree_form_node_form_alter(&$form, &$form_state, $form_id) {

  // Only show submenutree if menu is also editable
  if (!empty($form['menu'])) {
    $node = $form['#node'];
    $form['submenutree'] = array(
      '#type' => 'fieldset',
      '#group' => 'additional_settings',
      '#title' => t('Submenu tree settings'),
      '#access' => user_access('administer submenu trees'),
      '#collapsible' => true,
      '#collapsed' => empty($node->submenutree_enable),
      'submenutree_enable' => array(
        '#type' => 'checkbox',
        '#title' => t('Enable submenu trees for this node'),
        '#default_value' => !empty($node->submenutree_enable),
      ),
      'submenutree_title' => array(
        '#type' => 'textfield',
        '#title' => t('Title'),
        '#default_value' => isset($node->submenutree_title) ? $node->submenutree_title : '',
        '#description' => t('The title of the submenu tree content or block. If you leave this blank, the submenu tree content will have no title, or the submenu tree block will use the node title.'),
      ),
      'submenutree_display' => array(
        '#type' => 'select',
        '#title' => t('Display submenu trees as'),
        '#options' => array(
          'content' => array(
            SUBMENUTREE_DISPLAY_MENU => t('Menu'),
            SUBMENUTREE_DISPLAY_TITLES => t('Titles only'),
            SUBMENUTREE_DISPLAY_TEASERS => t('Teasers'),
            SUBMENUTREE_DISPLAY_TEASERS_LINKS => t('Teasers with links'),
            SUBMENUTREE_DISPLAY_FULLTEXT => t('Full text'),
            SUBMENUTREE_DISPLAY_FULLTEXT_LINKS => t('Full text with links'),
          ),
          'block' => array(
            SUBMENUTREE_DISPLAY_BLOCK_MENU => t('Menu'),
            SUBMENUTREE_DISPLAY_BLOCK_TITLES => t('Titles only'),
            SUBMENUTREE_DISPLAY_BLOCK_TEASERS => t('Teasers'),
            SUBMENUTREE_DISPLAY_BLOCK_TEASERS_LINKS => t('Teasers with links'),
            SUBMENUTREE_DISPLAY_BLOCK_FULLTEXT => t('Full text'),
            SUBMENUTREE_DISPLAY_BLOCK_FULLTEXT_LINKS => t('Full text with links'),
          ),
        ),
        '#default_value' => isset($node->submenutree_display) ? $node->submenutree_display : SUBMENUTREE_DISPLAY_MENU,
        '#description' => t('Select where and how the submenu tree should be displayed. If selecting a block display, the block also needs to be made visible.'),
      ),
      'submenutree_weight' => array(
        '#type' => 'weight',
        '#title' => t('Weight'),
        '#default_value' => isset($node->submenutree_weight) ? $node->submenutree_weight : 1,
        '#description' => t('The weight of the submenu tree listing. This only applies when displaying as content and affects where the submenu tree appears in the content.'),
      ),
    );
    $form['siblingmenutree'] = array(
      '#type' => 'fieldset',
      '#group' => 'additional_settings',
      '#title' => t('Siblingmenu tree settings'),
      '#access' => user_access('administer siblingmenu trees'),
      '#collapsible' => true,
      '#collapsed' => empty($node->siblingmenutree_enable),
      'siblingmenutree_enable' => array(
        '#type' => 'checkbox',
        '#title' => t('Enable siblingmenu trees for this node'),
        '#default_value' => !empty($node->siblingmenutree_enable),
      ),
      'siblingmenutree_title' => array(
        '#type' => 'textfield',
        '#title' => t('Title'),
        '#default_value' => isset($node->siblingmenutree_title) ? $node->siblingmenutree_title : '',
        '#description' => t('The title of the siblingmenu tree content or block. If you leave this blank, the siblingmenu tree content will have no title, or the siblingmenu tree block will use the node title.'),
      ),
      'siblingmenutree_display' => array(
        '#type' => 'select',
        '#title' => t('Display siblingmenu trees as'),
        '#options' => array(
          'content' => array(
            SUBMENUTREE_DISPLAY_MENU => t('Menu'),
            SUBMENUTREE_DISPLAY_TITLES => t('Titles only'),
            SUBMENUTREE_DISPLAY_TEASERS => t('Teasers'),
            SUBMENUTREE_DISPLAY_TEASERS_LINKS => t('Teasers with links'),
            SUBMENUTREE_DISPLAY_FULLTEXT => t('Full text'),
            SUBMENUTREE_DISPLAY_FULLTEXT_LINKS => t('Full text with links'),
          ),
          'block' => array(
            SUBMENUTREE_DISPLAY_BLOCK_MENU => t('Menu'),
            SUBMENUTREE_DISPLAY_BLOCK_TITLES => t('Titles only'),
            SUBMENUTREE_DISPLAY_BLOCK_TEASERS => t('Teasers'),
            SUBMENUTREE_DISPLAY_BLOCK_TEASERS_LINKS => t('Teasers with links'),
            SUBMENUTREE_DISPLAY_BLOCK_FULLTEXT => t('Full text'),
            SUBMENUTREE_DISPLAY_BLOCK_FULLTEXT_LINKS => t('Full text with links'),
          ),
        ),
        '#default_value' => isset($node->siblingmenutree_display) ? $node->siblingmenutree_display : SUBMENUTREE_DISPLAY_MENU,
        '#description' => t('Select where and how the siblingmenu tree should be displayed. If selecting a block display, the block also needs to be made visible.'),
      ),
      'siblingmenutree_weight' => array(
        '#type' => 'weight',
        '#title' => t('Weight'),
        '#default_value' => isset($node->siblingmenutree_weight) ? $node->siblingmenutree_weight : 1,
        '#description' => t('The weight of the siblingmenu tree listing. This only applies when displaying as content and affects where the siblingmenu tree appears in the content.'),
      ),
    );
  }
}