function faq_categories_settings_form in Frequently Asked Questions 6
Same name and namespace in other branches
- 5.2 faq.module \faq_categories_settings_form()
- 5 faq.module \faq_categories_settings_form()
- 7.2 faq.admin.inc \faq_categories_settings_form()
- 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 - Implements hook_menu().
File
- ./
faq.admin.inc, line 190 - Administrative page callbacks for the faq module.
Code
function faq_categories_settings_form() {
$categorization_enabled = variable_get('faq_use_categories', FALSE);
$vocabularies = array();
$vocab_omit = array();
$vocab_options = array();
// Display error messages if the taxonomy module isn't enabled or if there is
// no valid FAQ vocabulary.
if (!module_exists("taxonomy")) {
drupal_set_message(t('Categorization of questions will not work without the "taxonomy" module being enabled.'), 'error');
}
else {
$vocabularies = taxonomy_get_vocabularies('faq');
$vocab_omit = variable_get('faq_omit_vocabulary', array());
foreach ($vocabularies as $vid => $vobj) {
$vocab_options[$vid] = $vobj->name;
}
}
drupal_add_js(array(
'faq' => array(
'faq_hide_qa_accordion' => variable_get('faq_hide_qa_accordion', FALSE),
),
), 'setting');
drupal_add_js(array(
'faq' => array(
'faq_category_hide_qa_accordion' => variable_get('faq_category_hide_qa_accordion', FALSE),
),
), 'setting');
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 and you must configure a FAQ vocabulary at <a href="@url">Content Management > Taxonomy</a>.', array(
'@url' => url('admin/content/taxonomy'),
)),
'#default_value' => $categorization_enabled,
);
$category_options['none'] = t("Don't display");
$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_category_hide_qa_accordion'] = array(
'#type' => 'checkbox',
'#title' => t('Use accordion effect for "opens/hides questions and answers under category" layout'),
'#description' => t('This enables an "accordion" style effect where when a category is clicked, the questions appears beneath, and is then hidden when another category is opened.'),
'#default_value' => variable_get('faq_category_hide_qa_accordion', FALSE),
);
$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,
);
if (!empty($vocab_options)) {
$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', array()),
'#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),
);
}
$form['#submit'][] = 'faq_categories_settings_form_submit';
return system_settings_form($form);
}