How to add Views templates into a module instead of a theme
You can use the hook_views_api to tell where is your template files are.
/**
* Implements hook_views_api().
*/
function MODULENAME_views_api() {
return array(
'api' => 3,
'template path' => drupal_get_path('module', 'MODULENAME') . '/templates',
);
}
Now when you export your Features, it creates a module and MODULENAME.features.inc file contains function so MODULENAME_views_api you cannot declare the same again or alter it. So, in that case, you need to do the following.
/**
* Implements hook_views_api_alter().
*
*/
function MODULENAME_views_api_alter(&$apis) {
if (!empty($apis['MODULENAME']) && $apis['MODULENAME']['api'] == '3.0') {
$apis['MODULENAME']['template path'] = drupal_get_path('module', 'MODULENAME') . '/templates';
}
}
© Heshan Wanigasooriya.RSS🍪 This site does not track you.