3

Ive created a new taxonomy vocabulary. For some reason I cant remove the description field for the terms, but I only need the title field.

Is this a bug or impossible to do or are the settings hidden somewhere strange? Thanks

4 Answers 4

9

The description field is a main field. The equivalent to the body field in a node. If you dont need it you have 2 options.

1) You can just ignore it 2) You can use hook_form_alter to hide it for this (or all vocabularies)

There is no setting 'hide description field). If you want to hide the field from the form altogether let me know and I can explain hook_form_alter if you need me to. Otherwise when I don't need a description field in my taxonomy terms, i just leave it blank.

Edit to include the hook form alter

Information on hook_form_alter can be found here: http://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_form_alter/7

This can go either in your theme's template.php or a custom module, I'm going to assume your theme, and rather than the standard hook_form_alter we'll use hook_form_FORM_ID_alter

/*
* Implementation of hook_form_FORM_ID_alter
* 
* Hiding taxonomy term description field
*/

function YOUR_THEME_NAME_form_taxonomy_form_term_alter(&$form, &$form_state) {
  $form['description']['#access'] = FALSE;
}

Just change theme name for module name if your using a module

3
  • 1
    For the best possible answer. You should post the hook_form_alter example. Commented Jul 11, 2012 at 16:06
  • 2
    Just to clarify: The description on a taxonomy term is a property of the taxonomy_term entity type; it's not a field as such
    – Clive
    Commented Jul 11, 2012 at 16:33
  • You should be able to hide the 'Description' field in the form display, like any other field. Commented Mar 15, 2018 at 14:16
0

You can also use Display Suite and the included Display Suite forms module for this. In that case, choose a layout under "manage fields" on the term, then drag the description field into the hidden group.

0

I had a similar issue when using custom view modes with taxonomy terms and features.

In my case, I wanted to use the description field for input, but hide it for output on certain taxonomy view modes.

I found you can hide the description field in the vocabulary "Manage Display" page for that view mode. However, because it's not a full field API field, instead "description" is a hook_field_extra_fields provided term property, you also need to export the related strongarm variable for the taxonomy vocabulary to export the display settings for the "Description" field with features.

e.g, to export the settings for the topic description field, you need to export the variable:

field_bundle_settings_taxonomy_term__topics

It contains data such as:

 'extra_fields' => array(
      'display' => array(
        'description' => array(
          'default' => array(
            'weight' => '1',
            'visible' => TRUE,
          ),
          'tile' => array(
            'weight' => '1',
            'visible' => FALSE,
          ),
        ),
      ),
    )

Just posting here in case useful to others googling.

0

To continue on David's answer:

This is how you can set the visibility of the description field via code:

  // Shows description field in default full view mode of topics term.
  $settings_term = field_bundle_settings('taxonomy_term', 'topics');
  $settings_term['extra_fields']['display']['description']['default']['visible'] = TRUE;
  $settings_term['extra_fields']['display']['description']['default']['weight'] = -9;
  field_bundle_settings('taxonomy_term', 'topics', $settings_term);

This will update the variable field_bundle_settings_taxonomy_term__topics that David mentions.

'default' refers to the view mode that is used in the taxonomy/term pages.

Set $settings_term['extra_fields']['display']['description']['default']['visible'] to FALSE to hide it from the output.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.