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?
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.
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
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
In Drupal 10, I managed to disable the admin theme for the user/{user}/edit page, as follows:
With the following code:
<?php
namespace Drupal\your_module\EventSubscriber;
use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection;
/**
* Route subscriber.
*/
final class RouteSubscriber extends RouteSubscriberBase {
/**
* {@inheritdoc}
*/
protected function alterRoutes(RouteCollection $collection) {
// Disables the admin theme for user edit page.
if ($route = $collection->get('entity.user.edit_form')) {
$route->setOption('_admin_route', FALSE);
}
}
}
Create or edit the your_module.services.yml file in order to register the route subscriber.
services:
your_module.route_subscriber:
class: Drupal\your_module\EventSubscriber\RouteSubscriber
tags:
- { name: event_subscriber }
As an alternative you can also patch the core file web/core/modules/user/src/Entity/UserRouteProvider.php or use contrib module to switch theme. See this comment on drupal.org