0

I've seen how to override module templates from other modules and theme templates from subthemes, but how do I override module from subtheme? The file is under the profiles folder.

Edit:

I'm using Open Atrium. I want to override this file:

/var/www/openatrium/profiles/openatrium/modules/apps/oa_home/oa-home-default.tpl.php

From my subthem wich is located at:

/var/www/openatrium/sites/all/themes/my_radix/

The subtheme is working fine, but I need to override some .tpl.php files that are not part of the parent theme. How can I do that? Where do I copy them? How do I tell Drupal to use the new files?

2
  • can you be more descriptive .. explain module tpl name . subtheme's name other moduel's name etc. and are you using any distribution like kickstart ? Apr 3 '15 at 4:01
  • I added more info.
    – sker
    Apr 3 '15 at 4:22
2

Copy file from your module folder: /var/www/openatrium/profiles/openatrium/modules/apps/oa_home/oa-home-default.tpl.php and paste this to your subtheme in following path : /var/www/openatrium/sites/all/themes/my_radix/templates/oa-home-default.tpl.php

open this file and write something like this somewhere under php tags

 drupal_set_message('in new file');

go to admin/config/development/performance/ and clear all cache. Now when you visit to the page where the template is getting rendered, you'll see the message.

2
  • Thanks, I had tried that, but I was missing the cache part. Which also led me to discover my subtheme wasn't working fine, but I already fixed that too.
    – sker
    Apr 3 '15 at 4:41
  • awesome and congratulations :) Apr 3 '15 at 4:47
1

You would just need to copy that module tpl.php file into your sub-theme's folder. You can just place it in the root directory of your sub-theme or inside a folder named "templates" to be cleaner on your file structure.

Drupal looks for any tpl.php overrides and in that process, it will use the tpl.php file which is in your sub-theme.

2
  • Thanks, your answer is right too, but the cache was the problem, as pointed out by Himanshu.
    – sker
    Apr 3 '15 at 4:43
  • Oh! Yeah that's right! Thanks also! Glad you've got it! Apr 3 '15 at 4:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.