Short version
My aim is to theme a file field in a view of node fields. In the view configuration, the field formatter is set to Rendered file
and a view mode is selected. How do I suggest a template file?
Long version
What I see is, theming of a file entity is done through file_entity.tpl.php in file_entity
module. I copied this file to my theme folder and tried following names:
file_entity--my-view-mode.tpl.php
file-entity--my-view-mode.tpl.php
file_entity--views--my-view-mode.tpl.php
file-entity--views--my-view-mode.tpl.php
None worked. So I tried to hook in some suggestions like below as view_mode_templates.module
also does.
<?php
MYTHEME_preprocess(&$vars){
$vars['theme_hook_suggestions'][] = 'file_entity__views__my_view_mode';
}
?>
This ends up loading that file-entity--views--my-view-mode.tpl.php
but funnily I get an error like this:
Fatal error: Only variables can be passed by reference in blah/blah/file-entity--views--my-view-mode.tpl.php on line 71
Which is actually this line:
hide($content['links']);
Funnier thing is if I comment that line out, I get a fatality masterkill WSOD with no error message.
If I try to do it like below, again as view_mode_templates.module
does, it doesn't see the suggestion.
<?php
function MYTHEME_preprocess(&$vars) {
if (array_key_exists('file_entity', entity_get_info())) {
$vars['theme_hook_suggestions'][] = 'file_entity__views__my_view_mode';
}
}
?>
So, does it maybe not suggest the theme suggestion in the correct place? Do I need to suggest this in something like template_preprocess_file_entity(&$variables)
or template_preprocess_entity(&$variables)
? Which don't have the appropriate $vars['theme_hook_suggestions']
array as far as I couldn't see.
Any comment is hardcore appreciated, thanks.
MYTHEME_preprocess()
orMYTHEME_preprocess_file_entity()
?