I have found an issue,

If I add new group, and add group members or node to this group, as you can see on screenshot one time i have administration theme(Seven), but if I go to members tab or nodes i got loaded another theme. Testing as a admin.

I see that this two tabs(nodes and members) are in Views with paths /group/%group/nodes and /group/%group/members, so is there any quick fix to use only one theme in whole group?

Comments

Sebulec created an issue. See original summary.

Sebulec’s picture

Issue summary: View changes
kristiaanvandeneynde’s picture

Good catch, it's because they are views. Let's see if we can fix that :)

kristiaanvandeneynde’s picture

Category: Bug report » Feature request

I would argue that this needs to be added to core. If we have a simple UI toggle to say "admin route", then we don't need to guess what views people will be creating with Group.

sutharsan’s picture

I have no time to work in this now, but I do have some ideas which may help someone else.
The Members page is indeed a view. I agree with kristiaanvandeneynde that a setting in the view would be the best interface. To get a page to use the admin theme, the '_admin_route' option must be added to the route. The Views PathPluginBase::getRouteName() provides the route name of a view.

deciphered’s picture

I implemented a custom routing alter in my project to deal with this for myself. Find the code below for anyone who wishes to do so (note, this is just for the Nodes section at the moment):

YOUR_PROJECT/src/Routing/RouteSubsciber.php


namespace Drupal\YOUR_PROJECT\Routing;

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

/**
 * Class RouteSubsciber.
 *
 * @package Drupal\YOUR_PROJECT\Routing
 */
class RouteSubsciber extends RouteSubscriberBase {

  /**
   * {@inheritdoc}
   */
  public function alterRoutes(RouteCollection $collection) {
    if ($route = $collection->get('view.group_nodes.page_1')) {
      $route->addOptions(['_admin_route' => TRUE]);
    }
  }

}

YOUR_PROJECT/YOUR_PROJECT.services.yml

services:
  YOUR_PROJECT.route_subscriber:
    class: Drupal\YOUR_PROJECT\Routing\RouteSubscriber
    tags:
      - { name: event_subscriber }

Note: Code was edited here to remove identifiable project names and such, so hopefully no mistakes introduced.

markconroy’s picture

Hi Guys,

Can I piggyback on this issue to suggest that whatever theme is set as the admin theme should also be used when creating content inside a group?

At the moment, I have a role called 'Content Editor'. That content editor has permission 'View the administration theme'. However, when creating content inside a group, they are presented with the default theme. I guess this is because the path is group/%id/node/create/foo rather than node/add/foo

Sorry - my mistake, I hadn't added the correct user to my 'Content Editor' role.

kristiaanvandeneynde’s picture

Hey Deciphered, that's a correct approach you're listing there but it requires hard-coding the list of routes. I would prefer if core had a toggle in the Advanced section of a view saying "Use the admin theme" and then have a route subscribed pick that up.

kristiaanvandeneynde’s picture

deciphered’s picture

@kristiaanvandeneynde

I agree entirely, but I had need for the functionality now so I took my own path, the code is just for anyone else who also wishes to implement it now.

Thank you for the link, good to see there is progress being made on the real core issue.

tsi’s picture

Hi @Deciphered

You're missing few Rs in your comment. ctrl+f RouteSubsciber.

vbouchet’s picture

My current workaround until the core issue is fixed is to use admin_theme.

camslice’s picture

firewaller’s picture

Version: 8.x-1.0-beta2 » 3.3.x-dev
Component: Group (group) » Code
Status: Active » Needs review
Related issues: +#2719797: New option for Views page displays to use the admin theme
StatusFileSize
new422 bytes

New option for Views page displays to use the admin theme was merged to 10.1.x back in 2023.

I've added the config change to the module view against 3.3.x

Please note, if you've already exported the config locally you may need to make the same change to you config manually.