Last active
October 13, 2015 17:57
-
-
Save justin-endler/4233861 to your computer and use it in GitHub Desktop.
Register custom view templates from a module in Drupal 7.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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