You are here

function faq_categories_settings_form in Frequently Asked Questions 5.2

Same name and namespace in other branches
  1. 5 faq.module \faq_categories_settings_form()
  2. 6 faq.admin.inc \faq_categories_settings_form()
  3. 7.2 faq.admin.inc \faq_categories_settings_form()
  4. 7 faq.admin.inc \faq_categories_settings_form()

Define the elements for the FAQ Settings page - categories tab.

Return value

The form code inside the $form array.

1 string reference to 'faq_categories_settings_form'
faq_menu in ./faq.module
Implementation of hook_menu().

File

./faq.module, line 464
The FAQ module allows users to create a FAQ page, with questions and answers displayed in different styles, according to the settings.

Code

function faq_categories_settings_form() {
  if (!module_exists("taxonomy")) {
    drupal_set_message(t('Categorization of questions will not work without the "taxonomy" module being enabled.'), 'error');
  }
  drupal_add_js(drupal_get_path('module', 'faq') . '/faq.js', 'module');

  // Set up a hidden variable.
  $form['faq_display'] = array(
    '#type' => 'hidden',
    '#value' => variable_get('faq_display', 'questions_top'),
  );
  $form['faq_use_categories'] = array(
    '#type' => 'checkbox',
    '#title' => t('Categorize questions'),
    '#description' => t('This allows the user to display the questions according to the categories configured on the add/edit FAQ page.  Use of sub-categories is only recommended for large lists of questions.  The Taxonomy module must be enabled.'),
    '#default_value' => variable_get('faq_use_categories', FALSE),
  );
  $category_options['categories_inline'] = t('Categories inline');
  $category_options['hide_qa'] = t('Clicking on category opens/hides questions and answers under category');
  $category_options['new_page'] = t('Clicking on category opens the questions/answers in a new page');
  $form['faq_category_display'] = array(
    '#type' => 'radios',
    '#options' => $category_options,
    '#title' => t('Categories layout'),
    '#description' => t('This controls how the categories are displayed on the page and what happens when someone clicks on the category.'),
    '#default_value' => variable_get('faq_category_display', 'categories_inline'),
  );
  $form['faq_category_misc'] = array(
    '#type' => 'fieldset',
    '#title' => t('Miscellaneous layout settings'),
    '#collapsible' => TRUE,
  );
  $form['faq_category_misc']['faq_category_listing'] = array(
    '#type' => 'select',
    '#options' => array(
      'ol' => t('Ordered list'),
      'ul' => t('Unordered list'),
    ),
    '#title' => t('Categories listing style'),
    '#description' => t("This allows to select how the categories listing is presented.  It only applies to the 'Clicking on category opens the questions/answers in a new page' layout.  An ordered listing would number the categories, whereas an unordered list will have a bullet to the left of each category."),
    '#default_value' => variable_get('faq_category_listing', 'ul'),
  );
  $form['faq_category_misc']['faq_count'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show FAQ count'),
    '#description' => t('This displays the number of questions in a category after the category name.'),
    '#default_value' => variable_get('faq_count', FALSE),
  );
  $form['faq_category_misc']['faq_answer_category_name'] = array(
    '#type' => 'checkbox',
    '#title' => t('Display category name for answers'),
    '#description' => t("This allows the user to toggle the visibility of the category name above each answer section for the 'Clicking on question takes user to answer further down the page' question/answer display."),
    '#default_value' => variable_get('faq_answer_category_name', FALSE),
  );
  $form['faq_category_misc']['faq_group_questions_top'] = array(
    '#type' => 'checkbox',
    '#title' => t("Group questions and answers for 'Categories inline'"),
    '#description' => t("This controls how categories are implemented with the 'Clicking on question takes user to answer further down the page' question/answer display."),
    '#default_value' => variable_get('faq_group_questions_top', FALSE),
  );
  $form['faq_category_misc']['faq_hide_child_terms'] = array(
    '#type' => 'checkbox',
    '#title' => t('Only show sub-categories when parent category is selected'),
    '#description' => t("This allows the user more control over how and when sub-categories are displayed.  It does not affect the 'Categories inline' display."),
    '#default_value' => variable_get('faq_hide_child_terms', FALSE),
  );
  $form['faq_category_misc']['faq_show_term_page_children'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show sub-categories on FAQ category pages'),
    '#description' => t("Sub-categories with 'faq' nodes will be displayed on the per category FAQ page.  This will also happen if 'Only show sub-categories when parent category is selected' is set."),
    '#default_value' => variable_get('faq_show_term_page_children', FALSE),
  );
  if (module_exists('taxonomy')) {
    $form['faq_category_advanced'] = array(
      '#type' => 'fieldset',
      '#title' => t('Advanced category settings'),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    );
    $vocab_options = array();
    $vocabularies = taxonomy_get_vocabularies('faq');
    foreach ($vocabularies as $vid => $vobj) {
      $vocab_options[$vid] = $vobj->name;
    }
    $form['faq_category_advanced']['faq_omit_vocabulary'] = array(
      '#type' => 'checkboxes',
      '#title' => t('Omit vocabulary'),
      '#description' => t('Terms from these vocabularies will be <em>excluded</em> from the FAQ pages.'),
      '#default_value' => variable_get('faq_omit_vocabulary', 0),
      '#options' => $vocab_options,
      '#multiple' => TRUE,
    );
    $form['faq_category_advanced']['faq_enable_term_links'] = array(
      '#type' => 'checkbox',
      '#title' => t('Enable FAQ taxonomy links'),
      '#description' => t('Node links to taxonomy terms will be re-written to point at the FAQ pages instead.'),
      '#default_value' => variable_get('faq_enable_term_links', 1),
    );
  }
  return system_settings_form($form);
}