Hi, I am currently using Processwire for a client project and am quite pleased with the ease of use and versatility.
Unfortunately I came across a problem I am not able to solve:
I have a multi-lang site where the home page path are as follows:
www.example.com/ -> german (default)
www.example.com/en/ -> english
...
I build a language switcher that first gets the current page and then displays links for the page in all the different languages.
<?php namespace ProcessWire; ?>
<ul class="lang-switcher">
<?php
$real_page = $pages->get($_SERVER['REQUEST_URI']);
foreach ($languages as $language) {
if (!$real_page->viewable($language)) {
continue;
}
// echo <li>...</li>
}
?>
</ul>
(I need to search for the real page because the language switcher is loaded inside of the menu which is an additional page/template which get loaded via
echo $pages->get("title='Main menu'")->render();
. When using $page->localURL() I get the /main-menu page.)
this works without problems for urls:
www.example.com/
www.example.com/test
www.example.com/en/test
...
But not for:
www.example.com/en/
I diagnosed that $pages->get("/en/") returns a NullPage instead of the english home page.
Do you have any idea why this is and how to fix it.
Thanks alot.