Hey there,
I got ‘en/industries’ and ‘de/unternehmen’, but how would I get the underlying $page
object? (Slugs were collected, no further data available … )
Thanks!
CHE1RON
Hey there,
I got ‘en/industries’ and ‘de/unternehmen’, but how would I get the underlying $page
object? (Slugs were collected, no further data available … )
Thanks!
CHE1RON
How about
$p = $site->index()->findBy('urlForLanguage', Url::home() . '/de/unternehmen');
Or if you don’t have to search the index, limit to the pages you need to search.
Seems like this “finds” only pages for my default language, eg “de/unternehmen”, but filtering for “en/company” yields no result
You are right, it only works when you are actually in the right language context (independent of default language).
I think your best bet would actually be to parse the string (even if you wrote on Discord that you want to avoid that).
Or you would need a custom method that loops through the languages, sets the site with $site->visit()
and then checks with the above method. Something like, but wrapped in a method:
$p = null;
foreach ($kirby->languages() as $language) {
$site->visit(page(), $language->code());
$p = $site->index()->findBy('urlForLanguage', Url::home() . '/en/industries');
if ($p) {
break;
}
}
dump($p);
Thanks for $site->visit()
- didn’t know this existed! - which kinda solves my problem!