Default templates are never discovered if a non-default display exists

Created on 16 October 2008, over 16 years ago
Updated 18 May 2023, almost 2 years ago

Trying to theme title fields in all views across the site, I created a views-view-field--default--title.tpl.php file, put it in the theme folder -- and nothing happens. When I select the Defaults tab on the Views editing page, I can see the the template under Theme:Information. However when I select a Page or other display, the template is not discovered.

The culprit appears to be this piece of code in handlers/views_handler_field.inc:

<?php
    if (!empty($display)) {
      $themes[] = $hook . '__' . $this->view->name  . '__' . $display->id . '__' . $this->options['id'];
      $themes[] = $hook . '__' . $this->view->name  . '__' . $display->id;
      $themes[] = $hook . '__' . $display->id . '__' . $this->options['id'];
      $themes[] = $hook . '__' . $display->id;
 ?>

As far as I understand the code, $display->id is either a specific display ID (e.g. page_1), or 'default'. So if I have defined a display in my view, $display->id is not 'default', and I'm not going to have views-view-field--default, views-view-field--default--title etc. in the $themes array ever.

💬 Support request
Status

Fixed

Version

2.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

No activities found.

Production build 0.71.5 2024