Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Register custom view templates from a module in Drupal 7.
<?php
/**
* 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(
'template_preprocess',
'template_preprocess_views_view_fields',
'mymodule_preprocess_views_view_fields__myview',
),
);
return $themes;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.