I am not sure if this is a bug, or if I am doing something wrong.
I have a style plugin, 'mystyle'. And I created a view, 'myview', with style set to 'mystyle'.
Here is the declaration of 'mystyle' in hook_view_plugins:
function mymodule_views_plugins() {
$plugins = array(
'module' => 'mymodule',
'style' => array(
'mystyle' => array(
'title' => t('My Style'),
'handler' => 'mymodule_views_plugin_mystyle',
'theme' => 'mymodule_views_plugin_mystyle_template',
'uses fields' => TRUE,
'uses row plugin' => FALSE,
'uses options' => TRUE,
'uses grouping' => FALSE,
'type' => 'normal',
'even empty' => FALSE,
),
)
);
return $plugins;
}
I have the following files in mymodule/views:
handler:
mymodule_views_plugin_mystyle.inc
template associated with this style:
mymodule-views-plugin-mystyle-template.tpl.php
template associated with this style, and customized for the view 'myview':
mymodule-views-plugin-mystyle-template--myview.tpl.php
My problem:
Views is using the first, less specific, template (mymodule-views-plugin-mystyle-template.tpl.php) to display this view.
When I edit 'myview' and click on "theme information", I see both templates listed under "style output":
mymodule-views-plugin-mystyle-template.tpl.php
mymodule-views-plugin-mystyle-template--myview.tpl.php
The first, less specific, template is in bold. If I understand correctly, this means that views found the first template but did not find the second.
I have tried rescanning, but that does not help. I have also tried deleting the cache.
Should this work? What do I need to do to get views to find (and apply) the more specific template?
Comments
Comment #1
dawehnerDuplicate of #1876758: template associated with style plugin, and then customized for particular view: views does not find template
Comment #2
dawehnerUps, didn't looked in the other one.
Comment #3
dawehnerDrupal by default doesn't scan for more specific templates in modules directories, but views allows you to do it by adding 'template path'
to hook_views_api(), see http://api.drupal.org/api/views/views.api.php/function/hook_views_api/7
In general maybe it's better to rethink whether you want to handle such logic (specific templates per view) on module level, but sure this is just personal preference.
Comment #3.0
dawehnerclarification
Comment #4
kobnim CreditAttribution: kobnim commentedThank you, that worked!!
Comment #4.0
kobnim CreditAttribution: kobnim commentedclarification