I can see only the page ID is changing, but the rest of the classes are the same.
I even tried to create a second route in my main.js:
import home from './routes/home';
import pageId677 from './routes/home';
/** Populate Router instance with DOM routes */
const routes = new Router({
//...
// Home page
home,
pageId677,
//...
});
but it’s not working.
I have the same problem with other english pages (for instance, for a taxonomy that has the body class taxChallengeFamily and another regular page)
I’m using a console.log to see if the route is loaded (among other things that do not work), so I am sure that they are not loaded.
Sorry but how has this anything to do with js routing in Sage9 ?
As I mentioned, the body classes are similar between French and English, so could you elaborate?
Posting a link without any explanation in how this could sort my problem is not helpful at all.
You shouldn’t use page id’s as body class (they change for translations) but the template names! That way the routes are loaded for every page (incl. translations) using that template.
Seems like its just a fronted developer hired to work with wordpress, not php developer who trying to figure out how to change something in template trough javascript, and this is why his question its hard to understand even by him self…
I hope i am wrong and i wonder to see how the js routes works in wordpress.
That similar clases this is a normal behavior for every wordpress pages, what multilanguage is doing its only change the text content, not classes and some times not urls (if different domain in use).
You need to use code in php (not in javascript) to change this kind of stuff, for example hook in to the necessary filter to change class or other stuff. Like in pauloc example.
I eventually found that a (usually non blocking) error in the common.js was stopping the Router.js from working.
That error happened only on my English homepage because of a missing selector in the English version… The router was working in fact, the problem was somewhere else.
Thanks for your help! Somehow it put me on the right track (Compared to most other comments which were not helpful or offensive…)