body_attributes
No security coverage
Body Attributes provides a flexible way to add CSS classes and HTML attributes to page elements in Drupal based on configurable rules and conditions.
Features
- Rule-Based Targeting: Create multiple rules with custom priorities (weights).
- Flexible Zones: Target the html tag, body tag, or specific structural elements like header, main, and footer.
- Custom Selectors: Use CSS selectors to target specific elements on the page beyond standard structural tags.
- Visibility Conditions: Apply attributes based on:
- Request Path: Target specific pages or patterns (e.g., /blog/*).
- Node Type: Apply attributes only to specific content types (e.g., "Article" or "Product").
- Developer Friendly: Built using modern Drupal standards (PHP 8.1 Attributes, Strict Typing, and Service-oriented architecture).
How it Works
- Define a Rule: Navigate to Configuration > User Interface > Body Attributes.
- Choose a Zone: Select where you want the attribute applied.
- Set Attribute & Value: Define the class or HTML attribute (e.g., data-mode="dark").
- Set Conditions: Determine which pages or content types trigger the rule.