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());
}
Personal site
https://keiserjb.com/
Jacksonville Public Library
https://jaxpubliclibrary.org/
Academy of Model Aeronautics
https://nats.modelaircraft.org/
https...
Graham Leach: Has anyone got any experience with the assets in this area of Backdrop CMS?
filetransfer.inc
ftp.inc
local.inc
ssh.inc
If you do, I'd love to chat with you...
Graham...
Posted15 hours 33 min ago by Graham Leach (Graham Leach) on:
I've been building Backdrop sites since 2021 with the first being my own:
https://www.systemhorizons.co.uk/
Two over time for one client:
https://www....
Posted16 hours 17 min ago by Martin Price | System Horizons Ltd (yorkshirepudding) on:
Hi Tim. Yes I think at the moment it needs custom code:
/**
* Implements hook_preprocess_node().
*/
function theme_name_preprocess_node(&$variables) {
if (!$variables['...
Posted16 hours 49 min ago by Martin Price | System Horizons Ltd (yorkshirepudding) on:
With the threat of Drupal 7 EOL looming, and a very out of date Drupal 6 site that no longer worked with newer php versions, I made the decision to move both sites to Backdrop in March 2024. ...
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: