3

Drupal 8 - I have the following issue:

The problem is that the password reset page uses the administrator theme, while I need it uses the default site theme.

3

You can use a RouteSubscriber to do that but it will also affect your user edit form and render it with the default site theme since it uses the same route name. The RouteSubscriber can't alter a route based on a query string parameter such as pass-reset-token

yourmodule/yourmodule.services.yml

services:
  yourmodule.routesubscriber:
    class: Drupal\yourmodule\Routing\YourmoduleRouteSubscriber
    tags:
      - { name: event_subscriber, priority: 1 }

yourmodule/src/Routing/YourmoduleRouteSubscriber.php

<?php

namespace Drupal\yourmodule\Routing;

use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection;

/**
 * Custom route subscriber.
 */
class YourmoduleRouteSubscriber extends RouteSubscriberBase {

  /**
   * {@inheritdoc}
   */
  protected function alterRoutes(RouteCollection $collection) {
    if ($route = $collection->get('entity.user.edit_form')) {
      $options = $route->getOptions();
      $options['_custom_theme'] = 'yourthemename';
      $route->setOptions($options);
    }
  }

}

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.