I have a problem getting children of a page in a specific language. I asked (link -> Remove parent page name in subpage url)
few months ago to remove parent page in subpage url. Thats run correctly but the problem is that my page is multilanguage and when I’m going to find the subpages of my page allways get default language pages and kirby can’t find the page:
$categories = page('blog')->children()->pluck('uri', ','); //<-- here gets children of default language
$i = 0;
while($i < count($categories)) {
if($page = page($categories[$i].'/'.$uid)) {
return site()->visit($page);
}
$i++;
}
You are using site()->visit($page, 'en');. But I guess you would need to call it with the language code of the language that you want, not hardcoded en.
Yes, I have that route only for ‘en’ routes. My page is in Spanish (default language) and when y search the children of the page ‘nuestras-noticias’ the method gets Spanish children, not English children so in the while It isn’t being found the page.
I’ve tried to print the children in a template and there the values ​​change depending on the language. I don’t understand why with the same code, in config file doesn’t run same as in a template. Does this help you?
I have also put page('our-news') (The name of the page of the English version) instead of page('nuestras-noticias') but it does not work either.
Could you send me your project as a zip for testing, I don’t have the time to recreate such a setup at the moment. Then I can look into it over the weekend.