I used the "User Guide" recipe to create a user guide on a site that I upgraded from Drupal 7. 

I added "/admin" to the path for all book pages and expected these pages to automatically use the admin theme. But, these pages are displaying using the main front end theme. 

Don't all /admin pages use the admin theme? 

What else might be causing these pages to use the front end theme?

Accepted answer

Another contrib module that will meet this use case is Layout Custom Theme

Comments

I just created a basic content type with a url alias of `/admin/user-guide/[node-title]` and confirmed that it uses the front end theme.

There must be something that is doing it rather than the path. Interestingly, views pages with an admin path seem to use the admin theme, so I'm not sure where the switch is.

StPaulTim, adding "admin/" to alias path will not force B to use the administration theme. There is a difference between having "admin/" in the REAL path, and having it in the alias. The alias is cosmetic - not functional. 

In order to make this work, you'll need to write a custom module that implements hook_admin_paths, and make `node/*` pull up the admin theme. Note that ALL nodes will, from now on, use the admin theme. There is no way around it by using this hook. But there may be other workarounds we could explore if you are still interested. 

@argiepiano - As I mentioned, I'm using the "User Guide" recipe which enables the book module and creates a bunch of book pages as an initial user guide that a site admin can update and customize. 

This user guide looks awful in our current custom theme, so I thought maybe I could make all book pages to use the admin theme only, since the user guide is only for admins. 

Is there a couple of lines of code I could write to make only ONE content type use the admin theme? It's ok if all nodes of that content type use the admin theme, but I don't want ALL nodes on the site to use the admin theme. 

It would be interesting if we could apply a specific theme or the admin theme to a specific layout. Could someone write a contrib theme that does that!

I will try this module to see if it does what I want.
https://github.com/backdrop-contrib/content_theme

EDIT: The Content Theme module does seem to do what I would like. You are able to set a specific theme for each content type with this module. My initial test was successful. I will report back if I encounter any problems with this module.

IF you wanted to do this in code:

1. Implement hook_custom_theme()

2. In it, check the current menu router item. If it matches your pattern, return the machine name of the theme you want to use

This is untested:

function MY_MODULE_custom_theme() {
  $item = menu_get_item();
  $alias = backdrop_get_path_alias($item['path']);
  if (strpos($alias, 'book-page') !== FALSE) {
    return 'seven'; // Or your admin theme machine name.
  }
}