Add a system for adding a class to the body tag of an example page

Created on 26 April 2024, 7 months ago
Updated 7 June 2024, 6 months ago

Problem/Motivation

We use UI Example to build example pages with the front-end team, which facilitates back-end integration.
Drupal allows you to add classes in the body tag. Some of these are quite useful for front-end development.

For example, user-logged-in, is-front, page-node-type-[bundle]. These classes applied to the body enable global management to be applied to certain pages.
However, UI Examples won't inherit classes like the one added for a node-type-news content type/ is-front.

We could use a preprocess_html but I'm a bit worried about having code specific to the example mixed in with the preprocess linked to the project.

Proposed resolution

Would it be possible to add a mechanism that would add the classes to the body of an example page? Via the "additional" property for example?

Like : <body class="not-front page-node-type-news"></body>

Thanks in advance for your feedback, expertise

📌 Task
Status

Postponed: needs info

Version

1.0

Component

Code

Created by

🇷🇪Réunion Martygraphie Saint-Denis (Réunion)

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

Comments & Activities

  • Issue created by @Martygraphie
  • Assigned to pdureau
  • 🇫🇷France Grimreaper France 🇫🇷

    Hi,

    Assigning to @pdureau to get his feedbacks.

    Here are mines.

    1: Acting on body tag is out of the scope of this module
    2: We have added in such classes in UI Suite Bootstrap: https://git.drupalcode.org/project/ui_suite_bootstrap/-/blob/5.0.x/templ..., we did that to ease the theme adoption even if we are against such practices (maybe one day I will be fed up with that and remove it). It should not be a "global" class that impact the components/layouts, etc.
    3: The UI Skins theme feature allows to act on the body tag, but it will be global. Maybe you can give a look at how it works and adapt to your needs. Maybe this feature request should be opened on UI Skins, but in this case, I think the issue needs a proper concrete use case/example.

    So in my opinion it will be a "Closed (works as designed)".

  • Issue was unassigned.
  • Status changed to Postponed: needs info 6 months ago
  • 🇫🇷France pdureau Paris

    1: Acting on body tag is out of the scope of this module

    Indeed.

    3: The UI Skins theme feature allows to act on the body tag, but it will be global. Maybe you can give a look at how it works and adapt to your needs. Maybe this feature request should be opened on UI Skins, but in this case, I think the issue needs a proper concrete use case/example.

    Ye,s we need a proper example to answer this question.

    So in my opinion it will be a "Closed (works as designed)".

    I agree, but we can first wait for a proper example. Marc-Antoine, can you share?

Production build 0.71.5 2024