Answer the question
In order to leave comments, you need to log in
What would be the best way to override css depending on the page path?
I'm making a site on modx. The task is to make an individual background for each section of the site. Now it's done like this
$(document).ready(function(){
if(document.location.pathname.indexOf("/razdel/") == 0){
$('.main-content').css("background", "url('/img/razdel_bg.jpg')");
}
});
Answer the question
In order to leave comments, you need to log in
Yes, the easiest option is to use variables in the template, as Maxim Zaitsev advised you.
You can also do it through MODX modifiers, which will check the page id and include the desired style, for example, include the <head>
construction after the main style:
and in esle it is still possible to place a modifier.
Another option is to connect the <head>
structure after the main style:
, i.e. MODX will generate a link to a css file named page_(current page resource id), and create css files for the pages you need, for example, page_12.css, page_23.css, etc.
If you don't know the nesting level of the page path - follow from the site root to the css folder. Everything is generally simple.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question