Using the Group module, when a user views a group, I want to use a different view mode depending on whether the user is a member of the group or not.
Conceptually, this is almost identical to showing a different view mode of a node depending on the user role.
I'd have thought it was easy, but I'm struggling. What I know:
- The route is entity.group.canonical
I can modify the result of that route using
alterRoutes()
in a route subcriberprotected function alterRoutes(RouteCollection $collection) { if ($route = $collection->get('entity.group.canonical')) { // Do something. } }
I'm not sure how to modify the route. Swapping in a whole new custom controller seems extreme.