I have a template file for a entity type inside my theme's folder.

How can I use the same template file in the admin area which uses the Seven theme?

Thanks. M

  • I would go with a custom module so you wont have to modify the "core theme"'s template.php file. You'd have to add a new template path so Drupal knows about it since it would only check in the admin theme's template folder. The reason why I don't write this as an answer is because I don't have the time to be more elaborate and give examples.
    – hampusn
    Oct 12, 2012 at 13:49
  • @hampusn I reckon that's worthy of an answer in it's own right, the page you linked to has some great examples and you've fleshed out the process nicely :)
    – Clive
    Oct 12, 2012 at 13:51
  • @hampusn you should write it as an answer Oct 12, 2012 at 15:19
  • Sure thing then. I'm not working now so I guess I could spare some time :)
    – hampusn
    Oct 12, 2012 at 18:09

2 Answers 2


Since it's always bad practice to hack core, you would have to do it with a custom module. This would be done with either template suggestion overrides or with template suggestions in a preprocess hook such as template_preprocess_node or template_preprocess_page.

Unfortunately this is not enough when you place the template file (tpl) anywhere but the theme's templates/ folder. Your custom module's template folder is not known by default so you will have to notify Drupal about. To do this, you will need to use hook_theme_registry_alter. Here below is an example from one of my projects in Drupal 7 (and it's live and works).

 * Implements hook_theme_registry_alter()
function CUSTOM_MODULE_theme_registry_alter(&$theme_registry) {
  // The Templates path in your custom module you want to add...
  $mod_path = drupal_get_path('module', 'CUSTOM_MODULE') . '/includes/templates';

  // ... or the Templates path in your custom theme.
  // If you use your already existing custom theme's path, make sure you remember that this 
  // function exists when you alter or disable the custom theme.
  $mod_path = drupal_get_path('theme', 'CUSTOM_THEME') . '/templates';

  $theme_registry_copy = $theme_registry;
  _theme_process_registry($theme_registry_copy, 'phptemplate', 'theme_engine', 'pow', $mod_path);
  $theme_registry += array_diff_key($theme_registry_copy, $theme_registry);
  $hooks = array('node');
  foreach ($hooks as $h) {
    _CUSTOM_MODULE_insert_after_first_element($theme_registry[$h]['theme paths'], $mod_path);

 * Helper function for re-ordering arrays (needed by theme_registry_alter)
function _CUSTOM_MODULE_insert_after_first_element(&$a, $element) {
  if(is_array($a)) {
    $first_element = array_shift($a);
    array_unshift($a, $first_element, $element);

I've seen people advocate (or at least suggest) the use of theme_hook() instead, but I actually find the theme registry way a lot easier to handle. Especially when you add more templates at a later stage during the development process.

  • Nice! I wonder if you could use the custom theme path instead of the module path so Marius doesn't need to duplicate that template file? Also I've used this method before and never understood why passing pow as the theme name works (it doesn't seem to work with any other theme name). Do you have any idea?
    – Clive
    Oct 12, 2012 at 19:00
  • I've updated with an alternative $mod_path declaration for a theme. It should be noted that if you use the theme path and that theme later is moved/deleted/disabled, things could go bad. Regarding pow. I have actually never reflected over why I use that. It's probably because the first example I saw with it used that. Anyways, I can't seem to get it to not work with anything else. I've tried with all standard theme names, as well as totally random ones and also an empty string. It always picks out my custom template file. I'll continue digging.
    – hampusn
    Oct 13, 2012 at 10:46

You have a choice.

Goto host.com/admin/appearance

Scroll down to find ADMINISTRATION THEME

And uncheck the check box "Use the administration theme when editing or creating content"

  • The question was how to use another theme's template not how to disable the administration theme settings :) Oct 12, 2012 at 13:35
  • Yeah i got it. The idea is say, when you enable other theme for front end and use Garland as admin theme. You can surely use other themes template in admin. What you say?
    – niksmac
    Oct 12, 2012 at 13:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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