2

In Drupal 7.22, I want to override 'views-view-fields.tpl.php' views module with custom 'coutforum' module.

The steps I've followed include:

1- renaming the 'views-view-fields.tpl.php' to 'views-view-fields--coutforum.tpl.php' in my custom 'coutforum' module, as per the Drupal convention of adding the double dash & suffix of my custom module.

2- Updated the code in 'coutforum.module' file:

function coutforum_preprocess_views_view_fields(&$vars) {
  if (isset($vars['view']->name)) {
    $vars['theme_hook_suggestions'] []= 'views_view_fields__coutforum';
    }
  }
function coutforum_theme_registry_alter(&$theme_registry) {
    $theme_registry['views_view_fields__coutforum'] = array(
        'theme paths' => $theme_path,
        'template' =>'views-view-fields--coutforum',
        'path' => $theme_path,
    );
}

Code written so far is working correctly, however have the following error:

  1. Notice: Undefined index: type in theme() (line 1158 of /var/www/drupal-7.22/includes/theme.inc).
  2. Notice: Undefined index: #title in template_preprocess_field() (line 1037 of /var/www/drupal-7.22/modules/field/field.module).

Question: How can I define the theme 'type' in template_preprocess_field() / theme registry?

  • Is content of 'views-view-fields.tpl.php' identical to 'views-view-fields--coutforum.tpl.php' for now? – Mołot May 23 '13 at 6:04
  • @Mołot no content is not same. i have totally changed code in 'views-view-fields--coutforum – sarfraz May 24 '13 at 5:47
  • Is this happening when you put original .tpl.php file under 'views-view-fields--coutforum.tpl.php' name, and move your own out? If not, then it's something within your tpl file, and we will not be able to answer without seeing it. If yes, then we can look using standard files. – Mołot May 24 '13 at 6:42
  • ok my views-view-fields--coutforum.tpl.php code is : '<h3 class="cHeading"><?php print $fields['title']->content; ?></h3><div class="cComments"> <div class="cCommentsNo"><?php print $fields['comment_count']->content; ?></div> <div class="cCommentTxt">comments</div> </div> <div class="cBy"> <div class="cByTxt">by&nbsp;</div> <div class="cConvAuthor"><?php print $fields['uid']->content; ?></div> <div class="cInTxt">&nbsp;in</div> <div class="cInCategory"><?php print $fields['taxonomy_forums']->content; ?></div> </div> ' – sarfraz May 24 '13 at 11:51
  • i past in the same code from views-view-fields.tpl.php in views-view-fields--coutforum.tpl.php, but still issue.. – sarfraz May 24 '13 at 11:56

Your Answer

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

Browse other questions tagged or ask your own question.