7

I want the administration theme for all the default pages, except one: /user/%/edit

How do I get the default theme to display for this page instead of the administration theme?

11

For Drupal 7 you can use Administration theme or hook_admin_paths_alter() in your custom module.

/**
 * Implements hook_admin_paths_alter().
 */
function my_module_admin_paths_alter(&$paths) {
  $paths['user/*/edit'] = FALSE;
}

For Drupal 8, see https://www.drupal.org/node/2224207.

0
1

I believe ThemeKey allows you to control that: https://drupal.org/project/themekey

If that doesn't work, you can force a specific theme for a page using: https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_custom_theme/7

0

For anyone looking for a D8 solution:

Filename: YOUR_MODULE.routing.yml

YOUR_MODULE.user_edit:
  path: '/user/{user}/edit'
  defaults:
    _entity_form: 'user.default'
    _title_callback: 'Drupal\user\Controller\UserController::userTitle'
  requirements:
    _entity_access: user.update
    user: \d+
  options:
    _admin_route: FALSE
4
  • It's better to alter the routes with route subscriber rather than defining a new one, like so: drupal.stackexchange.com/a/85675/14665 but setOptions needs to be used in this specific case. – David Apr 21 at 7:05
  • Thanks for your feedback I would be interested in why it's better. If you could provide an answer with that approach, that would be amazing! – ipwa Apr 21 at 7:25
  • Because that's the correct way of altering existing routes. I'll provide exact solution ijn a separate answer. – David Apr 21 at 7:26
  • Sounds good, I think my answers works well for beginner because it is super simple to implement. Looking forward to your approach altering the existing route instead of defining a new one that overrides the core route. – ipwa Apr 21 at 7:54

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.