I have created a custom view style in a module. It shows up in the list of view styles, but when I try to output the resulting block I get the message:

Warning: include(/var/www/core/modules/views/templates/mymodule-list.tpl.php) [function.include]: failed to open stream: No such file or directory in theme_render_template() (line 1491 of core/includes/theme.inc).

Warning: include() [function.include]: Failed opening '/var/www/core/modules/views/templates/mymodule-list.tpl.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in theme_render_template() (line 1491 of core/includes/theme.inc).

This obviously is trying to find my view template in the templates folder of the view module, but I want it to look in /sites/default/modules/mymodule/templates/.

My plugin class annotations look like this:

 * Style plugin
 * @ingroup views_style_plugins
 * @Plugin(
 *   id = "mymodule",
 *   title = @Translation("My Module"),
 *   help = @Translation("Help text"),
 *   theme = "mymodule-list",
 *   path = "sites/default/modules/mymodule/templates",
 *   type = "normal",
 *   module = "mycarousel"
 * )

I have also tried setting the path in hook_theme:

function mymodule_theme($existing, $type, $theme, $path) {
  return array(
    'mymodule' => array(
      'variables' => array(),
      'path' => drupal_get_path('module', 'mymodule') . '/templates',
      'theme' => 'mymodule-list',
      'theme path' => drupal_get_path('module', 'mymodule') . '/templates',

Can anyone see what I'm doing wrong?

  • What with code freeze not being until July 1st 2013, I'd be apprehensive to answer this.
    – Chapabu
    Mar 8, 2013 at 12:48
  • I'm happy to keep any answers up to date as core changes make them obsolete. Mar 8, 2013 at 12:50
  • There are still some bugs with the views theme annotations, see drupal.org/node/1911492 Mar 8, 2013 at 18:16
  • I am going to close this question, which can be re-opened after the code freeze.
    – apaderno
    Mar 9, 2013 at 2:04

1 Answer 1


I think instead of path = "sites/default/modules/mymodule/templates" you should have theme path = "sites/default/modules/mymodule/templates".

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