I've read from http://drupal.org/node/1089656 that I can create a template for a field in specific content type as field--field-name--content-type.tpl.php.

I have a custom content type "festivals_events" and a cck field "field_description". So, I created a template "field--field_description--festivals_events.tpl.php". But it is not working.

I tried to replace _ in field name with - as suggested in Template Suggestion, http://drupal.org/node/1089656, to become my template name file name as "field--field-description--festivals_events.tpl.php" This too is not working.

I think it is definitely can be used as it is mentioned in Template Suggestion. What is wrong with me?

Thanks in advance.


Try "-" in the contact type name like field--field-description--festivals-events.tpl.php

You may also need a template suggestion in your theme.

function mytheme_preprocess_field(&$variables) {
    if($variables['type'] == 'festivals-events'){
        if($variables['element']['#field_name'] == 'field_description') {
            $variables['theme_hook_suggestions'][] = 'field__field_description__festivals_events';

for me it worked great (field--field-name--content-type.tpl.php.). Drupal 7.26

But, first add in template.php

    function ThemeName_process_page(&$vars) {   
  if (!empty($vars['node'])) {
    $vars['theme_hook_suggestions'][] = 'page__'. $vars['node']->type;  

this also works with node-content-type.tpl.php

  • themename_process_page has nothing to do with field templates. – rooby Mar 15 '14 at 6:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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