backdrop-issues icon indicating copy to clipboard operation
backdrop-issues copied to clipboard

Add layout name in class for custom layout.

Open Graham-72 opened this issue 9 years ago • 2 comments

Currently almost at the beginning of our html we have, for example,

<div class="layout--boxton layout contextual-links-region">

Please, rather than just boxton-layout, could we have the machine name of a custom layout here so that it is easy to target styles for the layout?

Graham-72 avatar Jul 07 '16 14:07 Graham-72

In the meantime, it is possible to do this in template.php in a custom theme. In the example below, a layout named "Special page" with id "special_page" would get the class "layout-id--special-page".

function mytheme_preprocess_layout(&$vars) { // Add css class for custom layout name, with dashes instead of underscores. $layout_class = backdrop_clean_css_identifier($vars['layout']->name); $vars['classes'][] = 'layout-id--' . $layout_class; }

markabur avatar Jan 27 '17 17:01 markabur

In the meantime there is also a module for the use case: https://github.com/backdrop-contrib/layout_body_class

olafgrabienski avatar Nov 16 '25 16:11 olafgrabienski