Question

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?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with drupal.stackexchange
scroll top