Is there any way by which i could assign a template to my custom module.I heard it may be possible.I tried out with the hook_theme function.My hook_theme looks something like this
function special_theme() {
return array(
'special' => array(
'template' => 'special',
'arguments' => array('link' => NULL),
),
);
}
I do have a special.tpl.php file in my module folder.But the tpl file is not called.Its my default template that is been shown as output.Could someone please help me in the right direction.would be very helpful.
What you define via hook_theme()
is an available template, not one that is automatically used. In order to use that template you need to call theme('special', $link);
.
It is also advised to avoid using simple words for theme names to avoid collisions ( try mymodule_special
instead ).
Also note (though basic), that you also need to print
the return value of theme()
, it does not get automatically printed. So for instance,
print theme('special', $link);