Can you explain a bit more in detail what you are trying to do? When you say body, do you mean the body HTML tag? And what do you mean by a "URL alias"? Do you mean adding a string to the css class, taken from the alias being currently used by the page?
Typically, these types of things can be done by overriding the templates being used. In this case, the template page.tpl.php is the one in charge for rendering the html, head and body tags. This is different from D7.
In Backdrop the templates are also in core. The Page template file is at core/modules/system/templates/page.tpl.php. A good way to find other templates is the 'theme debug mode' which shows the templates used by the current page as comments in the HTML code. One way to enable the theme debug mode is to use the Devel module.
Another place to add a CSS class to the <body> tag which is based on the path alias of the current page, is the template.php file of your (custom) theme. The following code works for me:
function MYTHEME_preprocess_page(&$variables) {
// Add a body class with the path alias.
$variables['classes'][] = 'path-' . backdrop_clean_css_identifier(backdrop_get_path_alias());
}
Posted3 weeks 1 day ago by Martin Price | System Horizons Ltd (yorkshirepudding) in Weekly Meetings
Recent comments
Steve - long story short - this is a legacy site that was ported from Drupal 7 and had some tinkering done to it so that Brilliant Gallery code was interpreted. This avoided rewriting a few...
Hi yorkshirepudding - once again you leap to my rescue!
I thought I had it sussed after reading your reply but I found that creating a new field called Description, hiding the label and...
Hi Ian...,
Can you explain why you are using Paragraphs for this? Is it because you have a specific requirement that is only filled by Paragraphs? There are other ways to create an...
Hi Ian
You can go to Admin > Structure > Paragraph Types > Your paragraph Type > Manage displays > Paragraphs Editor Preview and adjust what shows there.
The path will...
Posted1 hour 55 min ago by Martin Price | System Horizons Ltd (yorkshirepudding) on:
It's not difficult to write JS code in an admin theme (without a module) that would save text from CKEditor to LocalStorage every X minutes and add a button to restore the text from LocalStorage...
Comments
Can you explain a bit more in detail what you are trying to do? When you say body, do you mean the body HTML tag? And what do you mean by a "URL alias"? Do you mean adding a string to the css class, taken from the alias being currently used by the page?
Typically, these types of things can be done by overriding the templates being used. In this case, the template page.tpl.php is the one in charge for rendering the html, head and body tags. This is different from D7.
That's exactly what I mean. D6 used to have the base templates in core, where can I find them in BD to copy?
In Backdrop the templates are also in core. The Page template file is at core/modules/system/templates/page.tpl.php. A good way to find other templates is the 'theme debug mode' which shows the templates used by the current page as comments in the HTML code. One way to enable the theme debug mode is to use the Devel module.
Another place to add a CSS class to the <body> tag which is based on the path alias of the current page, is the template.php file of your (custom) theme. The following code works for me: