0

Drupal 7 Website. Customize the links under "Tags" Screenshot 1: I want to make the links under "Tags" to customize its HTML not just tag. Mobile

Drupal 7 Website. Using website inspector Screenshot 2: The complete markup of "Tags" starting from with a class of "field-name-field-tags"

From the screenshots above, I want to customize the HTML markup for the autocomplete term widget(tagging) or just this particular field that I made. Where can I find the source file for this? Or how can I modify using a php script alter or related for drupal 7? Thanks!

RJ Ramirez
  • 269
  • 1
  • 4
  • 16

1 Answers1

0

To customize HTML markup for all fields taxonomy reference, you can use a custom template. To affect term reference field, you can copy the field.tpl.php from the core and make a file called field--taxonomy-reference--yourcontenttype.tpl.php (if you want to target only one content-type).

To apply your customization only to "tags" vocabulary (or/and "category" for example), you can test in a template_preprocess_field() function (added to your template.php) if you're in a "tags field" to use a custom template called field--taxonomy-custom.tpl.php (based on field.tpl.php as well). Example :

function YOURTHEME_preprocess_field(&$vars) {
  $field_names = array('field-name-field-tags', 'other-field-you-want', 'etc');

  if(in_array($element['#field_name'], $field_names) {
    $variables['theme_hook_suggestions'] = array('field__taxonomy-custom');
  }
}

Hope it helped :-)

Djouuuuh
  • 1,147
  • 8
  • 16