Answer the question
In order to leave comments, you need to log in
How to run different js code on different pages of the site?
Good afternoon everyone.
Please help me solve this problem.
There is an online store on cms MODX REVO - You need to run js code 1
in the /catalog/ section (this will be a pop-up window with a test), on all categories, subcategories, product cards that have /catalog/ in the url
- And js code should be run on
the whole site, except for the /catalog/ section
.
and write like:
if (window.location.pathname.indexOf('/catalog/') >= 0)) {
return functionone();
}
else {
return functiontwo();
}
Answer the question
In order to leave comments, you need to log in
I don’t know how to sew this inside the JS itself, but you can work out this or that scenario within the framework of a document or template:
выводим если шаблон не равен 12]]
выводим если ID документа равен 1 или 2 или 3]]
In MODX revo, you can always have templates that define the output of things like:
Here in them and write this script of yours. It makes no sense to study location. Because with one simple action, /catalog/ is renamed to /product/, but this does not change its essence. But your script will stop working
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question