I have a content type 'leg' and a template node--leg.tpl.php.
I'm using sky theme. I have a custom module as well, let's say for example, mymodule
.
I put the template file into sites/all/modules/mymodule/theme
. And I created a hook_theme
and hook_preprocess_node
.
But my template is not invoked as expected. I cleared all caches.
function mymodule_theme(){
// The base theme registers node.tpl.php.
$templates['node'] = array(
'arguments' => array('elements' => NULL),
'path' => drupal_get_path('module', 'mymodule') . '/theme',
'template' => 'node--leg',
'preprocess functions' => array(
'template_preprocess',
'mymodule_preprocess',
'mymodule_preprocess_node',
'mymodule_process',
),
);
return $templates;
}
function mymodule_preprocess_node(&$vars, $hooks){
if($vars['type'] == 'leg'){
}
}
When I put my template file into sites/all/themes/sky/templates
and changed path in hook_theme
to that location, it works.
function mymodule_theme(){
// The base theme registers node.tpl.php.
$templates['node'] = array(
'arguments' => array('elements' => NULL),
'path' => drupal_get_path('theme', 'sky') . '/templates',
'template' => 'node--leg',
'preprocess functions' => array(
'template_preprocess',
'mymodule_preprocess',
'mymodule_preprocess_node',
'mymodule_process',
),
);
return $templates;
}
I would like to know it is a right way or not.
I should not place my template in the sky theme folder, am I right ?