4

I have two template files for a view but only one of them is getting picked up. If I look under the Theme dialog for the view I can see that my two theme files are bolded.

enter image description here

The Display Output template file is working but the Row Style is not working. I've also added this to my template file to try try and get it to work but I don't think it's doing anything.

function mytheme_preprocess_views_view(&$variables){
  if ($variables['view']->name == 'travel_extras_hotel_carousel') {  
    $variables['theme_hook_suggestions'][] = 'views_view_fields__travel_extras_hotel_carousel__block';
    $variables['theme_hook_suggestions'][] = 'views_view__travel_extras_hotel_carousel__block';
  }
  return $variables;
} 

Does anyone have any ideas about what else I could do?

I'm using views 3.3

3
  • What is the content of your Row style template ? Did you try to output something simple from it, just to check if it changes anything ? I wouldn't fuddle with preprocess functions until I'm sure my custom template is working, just not to clutter the problem.
    – Countzero
    Feb 27, 2012 at 8:40
  • I was having the same issue. It seems that there are discrepancies between what renders in the preview below the view configuration and what actually renders on the page. Go to the view as it is rendered on a real page to see if the changes occur.
    – Loopy
    Mar 26, 2014 at 15:14
  • Are you using Drupal page caching or any external cache such as Varnish? Have you tried clearing the cache? Sep 8, 2016 at 13:48

1 Answer 1

1

Best way to learn something new about your project is not to ask "what is going on" but do own investigation. Try to debug as much things as possible. You can start by enabling Theme debug mode This is great feature implemented as of version 7.33

As Drupal documentation states:

As of Drupal 7.33, Drupal core has a theme debug mode that can be enabled and disabled via the theme_debug variable. Theme debug mode can be used to see possible template suggestions and the locations of template files right in your HTML markup (as HTML comments).

Place $conf['theme_debug'] = TRUE; variable in your settings.php file and use Developer Tool (F12) in your browser or any other tool that can help you see source HTML markup.

With theme debug mode you will be able to see all template suggestions and what tpl file was chosen to rendering. If your tpl file is really rendered you should see something like:

<!-- BEGIN OUTPUT from '(...)/views-view--travel-extras-hotel-carousel--block.tpl.php' -->

This way you will discover the cause and learn something new about your Drupal project.

Remeber to clear cache (at least theme registry cache) after each change connected with template files. This assures that your theme "knows" about tpl file. The same applies to preprocess or hook functions.

Remove mytheme_preprocess_views_view - try to solve initial problem first.

Your Answer

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

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