I have problem with template for field "field_is_new" in Drupal 7. My_Theme is a modification of the Garland theme. (I don't know if it's important.)

I have created a template for this field in my theme folder ("My_Theme/templates/field--field-is-new.tpl.php").

In template.php, I added:

function My_Theme_preprocess_field(&$variables, $hook) {
  // Add specific suggestions that can override the default implementation.
  array_unshift($variables['theme_hook_suggestions'], 'field__' . $variables['element']['#field_name']);

I cleared the cache, and rebuilt the theme.

I was thinking it's good way to do this, but it's not working. What's wrong?

1 Answer 1


Your preprocess function is not necessary in this situation because Drupal's default behavior is using this sort of files. Try print_r($variables['theme_hook_suggestions']); and see all relevant suggestions.

Your problem is the wrong filename; try field--field_is_new.tpl.php instead.

The general recommendation is using theme functions:

function theme_field__field_taxonomy($vars) {
  $output = '';

  foreach ($vars['items'] as $delta => $item) {
    $array = explode(';',$item['#markup']);

    if (count($array)) {
      $output = '<ul class="' . $vars['classes'] . ' clearfix"' . $vars['attributes'] . '>';
      foreach ($array as $value) {
          $output .= '<li>' . trim($value) . '</li>';
      $output .= '</ul>';

  return $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.