Allow adding a body class in a route / controller

Created on 9 November 2023, 10 months ago

Problem/Motivation

Adding a body class in a controller to indicate for example, which type of entity or page is currently handled doesn't seem to be possible
Using hook_preprocess_html() isn't helpful as it doesn't have a good way to determine the current controller / entity.

See https://drupal.stackexchange.com/questions/210376/how-can-i-add-a-css-cl... for similar questions

So the problem in behind is to get the information from the controller into the page / html.

Maybe this should be extended to a wider context of being able to change / attach page metadata in the controller, probably through the render array?

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Feature request
Status

Active

Version

11.0 🔥

Component
Theme 

Last updated 1 day ago

Created by

🇩🇪Germany Anybody Porta Westfalica

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024