8

According to Drupal handbook route definition accepts parameter called _theme. Unfortunately this parameter is documented as "TODO".

Can this be used to force admin theme for the route? Is it possible to inject config parameter with admin theme name here?

It appears that other solution is to use Theme negotiator however the _theme parameter looks very tempting and way simpler to use.

12

You're looking for the _admin_route option:

aggregator.feed_add:
  path: '/aggregator/sources/add'
  defaults:
    _controller: '\Drupal\aggregator\Controller\AggregatorController::feedAdd'
    _title: 'Add feed'
  requirements:
    _permission: 'administer news feeds'
  options:
    _admin_route: TRUE
  • 2
    Yet another undocumented D8 feature. – SiliconMind Dec 29 '15 at 17:41
  • 5
    Documentation might not be so great yet for D8 but change records are: drupal.org/node/2224207. Always search there if you know how something worked in D7 (found by seaching for "admin path"). drupal.org/developing/api/8/routing seems like a good place (subpage or so) to document this, looking forward to the documentation you'll write about this :) – Berdir Dec 29 '15 at 17:47
  • 1
    so does _admin_route just change it so it uses the default theme instead of the admin one? – Matt Jun 20 '17 at 14:09
  • 1
    I get a InvalidArgumentException: Routing requirement for "options" must be a string. when attempting to use this solution – Matt Jun 20 '17 at 14:30
2
module.myroute:
  path: '/path/path2'
  defaults:
    _controller: 'Drupal\module\Controller\MyController::add'
    _title: 'Add element'
  options:
    _admin_route: 'TRUE'

You need to use ' ' around TRUE, if not, you will get 'InvalidArgumentException: Routing requirement for "options" must be a string'

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.