By socketwench on
Can you override a tpl file in a module? For example, I want to override user-picture.tpl.php in a module to change the user icon display based on a user-entered selection on nodes, comments, and the user profile page.
Can you override a tpl file in a module? For example, I want to override user-picture.tpl.php in a module to change the user icon display based on a user-entered selection on nodes, comments, and the user profile page.
Comments
You should be able to copy
You should be able to copy the tpl.php file to your theme's folder and empty the cache so Drupal knows about it and then make changes.
Wonderful! Thanks!!!
Wonderful! Thanks!!!
a note about theme hook names
I just spent several hours debugging an odd theming issue where I was trying to use this technique (Drupal 6.16). I had a .tpl.php file in my custom module which worked properly, but copying this same .tpl.php file to the theme folder did nothing. I flushed the cache many times, tried running the module in another Drupal instance, various things, nothing worked - it was consistently busted.
The issue ended up being that both the name of theme hook and the tpl file had dashes in them, as opposed to what I assume to be the correct convention - using underscores in the theme hook name and dashes in the file name.
So this did NOT work (meaning the .tpl.php file was only found in the module folder):
But this DID work (copying the .tpl.php file to the theme folder automatically made that override the one in my module folder):
This appears to be due to some code in includes/theme.inc starting on line 909 where it is replacing underscores and dashes as part of the drupal_find_theme_templates() function.
Just a note for any other poor souls who run into this same issue... hopefully this'll show up in response to your googling.
It did show up! Thanx for the
It did show up! Thanx for the hours I earned and I would have missed if you hadn't posted this here :D