Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Register custom view templates from a module in Drupal 7.
* Implements hook_theme().
* Drupal 7 view template-ing from a module.
* @author Justin Endler
function mymodule_theme($existing, $type, $theme, $path) {
$module_path = drupal_get_path('module', 'mymodule');
// Add to theme registry.
// @todo the custom preprocess registration is ignored
$themes['views_view_fields__myview'] = array(
'template' => 'views-view-fields--myview',
'path' => $module_path . '/theme',
'base hook' => 'views_view_fields',
'type' => 'module',
'theme_path' => $module_path,
'preprocess functions' => array(
return $themes;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment