You are here

function ctools_node_terms_content_type_edit_form in Chaos Tool Suite (ctools) 6

Same name and namespace in other branches
  1. 7 plugins/content_types/node_context/node_terms.inc \ctools_node_terms_content_type_edit_form()

Returns an edit form for node terms display settings.

The first question is if they want to display all terms or restrict it to a specific taxonomy vocabulary.

Then, they're presented with a set of radios to find out how they want the terms formatted, which can be either be via theme('links'), a regular item list (ul), or inline with a delimiter. Depending on which radio they choose, some other settings might appear. If they're doing either the ul or inline, we ask if they want the terms to appear as links or not. If they want it inline, we ask what delimiter they want to use.

File

plugins/content_types/node_context/node_terms.inc, line 111

Code

function ctools_node_terms_content_type_edit_form(&$form, &$form_state) {
  ctools_include('dependent');
  $conf = $form_state['conf'];
  $options = array();
  $options[0] = t('- All vocabularies -');
  foreach (taxonomy_get_vocabularies() as $vid => $vocabulary) {
    $options[$vid] = $vocabulary->name;
  }
  $form['vid'] = array(
    '#title' => t('Vocabulary'),
    '#type' => 'select',
    '#options' => $options,
    '#default_value' => $conf['vid'],
    '#description' => t('Optionally restrict the terms to a specific vocabulary, or allow terms from all vocabularies.'),
    '#prefix' => '<div class="clear-block">',
    '#suffix' => '</div>',
  );
  $form['term_format'] = array(
    '#type' => 'radios',
    '#title' => t('Term formatting'),
    '#options' => array(
      'term-links' => t("Taxonomy links (uses theme('links'))"),
      'ul' => t('Unordered list'),
      'inline-delimited' => t('Inline, delimited'),
    ),
    '#default_value' => $conf['term_format'],
    '#prefix' => '<div class="clear-block">',
    '#suffix' => '</div>',
  );
  $form['link'] = array(
    '#title' => t('Link to terms'),
    '#type' => 'checkbox',
    '#default_value' => $conf['link'],
    '#description' => t('Check here to make the terms link to the term paths.'),
    '#process' => array(
      'ctools_dependent_process',
    ),
    '#dependency' => array(
      'radio:term_format' => array(
        'inline-delimited',
        'ul',
      ),
    ),
    '#prefix' => '<div class="clear-block">',
    '#suffix' => '</div>',
  );
  $form['term_delimiter'] = array(
    '#type' => 'textfield',
    '#title' => t('Term delimiter'),
    '#default_value' => $conf['term_delimiter'],
    '#size' => 10,
    '#process' => array(
      'ctools_dependent_process',
    ),
    '#dependency' => array(
      'radio:term_format' => array(
        'inline-delimited',
      ),
    ),
  );
}