In the following commit, a bunch of views templates (for fields) were removed: https://github.com/backdrop/backdrop-issues/issues/448

I need them back :) Can anyone give me an idea of which theme hook I'd use to reintroduce the ones that were removed?  And...I'm assuming template.php would be the place for this (as opposed to a module)?

Thanks for any direction...

Comments

This really depends on which type of view display you want to add this template suggestion to. Can you post a photo of the D7 views configuration > Theme: Information screen and circle the missing template there?

For example, if the missing template is in the "Style" category for a "table" display format (see below) then your custom module has to implement this hook

 

function MYMODULE_preprocess_views_view_table(&$variables) {
  $$variables['theme_hook_suggestions'] = YOUR_SUGGESTION;
}

Thanks for the input: I'd like to just re-add all the ones that were removed because this isn't to fix one particular view, but to ensure all the templates I was using in D7 work in Backdrop.

I believe those hook suggestions that were removed were all used for theming individual fields. I think this could work to bring them back:

 

function MYMODULE_preprocess_views_view_field(&$variables) {
  $view = $variables['view'];
  $handler = $variables['field'];
  $hook = 'views_view_field';
  $display = $view->display[$view->current_display];
  $options = $handler->options;
  $variables['theme_hook_suggestions'][] = $hook . '__' . $view->name  . '__' . $display->id . '__' . $options['id'];
  $variables['theme_hook_suggestions'][] = $hook . '__' . $view->name  . '__' . $display->id;
  $variables['theme_hook_suggestions'][] = $hook . '__' . $display->id . '__' . $options['id'];
  $variables['theme_hook_suggestions'][] = $hook . '__' . $display->id;
  if ($display->id != $display->display_plugin) {
    $variables['theme_hook_suggestions'][] = $hook . '__' . $view->name  . '__' . $display->display_plugin . '__' . $options['id'];
    $variables['theme_hook_suggestions'][] = $hook . '__' . $view->name  . '__' . $display->display_plugin;
    $variables['theme_hook_suggestions'][] = $hook . '__' . $display->display_plugin . '__' . $options['id'];
    $variables['theme_hook_suggestions'][] = $hook . '__' . $display->display_plugin;
  }
}

This function needs to be placed either in the template.php file of your theme (try putting it on both the front and back end themes, in which case you need to replace MYMODULE with the machine name of your theme, as in basis_), or in a custom module, in the .module file, in which case you need to replace MYMODULE with the module's name.

I haven't really tested this. The new template suggestions may not appear in the Views Theme: Information listing... but it should work if you put the appropriate template file in your theme's templates folder.

Again, untested.  

Wow, this is amazing...I didn't expect such an indepth answer, but I really appreciate it.  I'll give this a try today and let you know what turns out...

Implemented this and it's working in the one place I know I needed it (will keep an eye out to see if it's working everywhere).  HOWEVER, as you suspected, it does NOT show the template suggestions within the views templates display.  But...they are recognized correctly.


Thanks!