Multilingual single pages (as Page not Found etc)

Permalink
Can there be language-specific single pages in 5.7 Multilingual environment, when there are several content sections in different languages? I have the following problem. Naturally, on my site I have typical global areas with AutoNav and Language Switch, which display pages and languages relative for the current language section only.

Now as Page Not Found is a single page residing in the root of the sitemap, it does not belong to any language section. Therefore, on the Page Not Found page the main menu is empty, because there is no "second level" for AutoNav (see screenshots). Whereas if a user access an URL like /en/non-existing-page (where /en/ is one of my language sections), I would expect Page Not Found to understand that the current language section is "/en/".

I tried copying Page Not Found pages in the Sitemap under my content sections, but it didn't help. Adding language specific paths to app.php like this also didn't help:

return array(
  'theme_paths' => array(
    '/page_not_found' => 'MyTheme',
    '/en/page_not_found' => 'MyTheme',
  )
);


So, can anyone shed some light on the proper handling of the situation?

3 Attachments

snobo
View Replies:
Jozzeh replied on at Permalink Reply
Jozzeh
i have just encountered the same problem. This page is easely found in google when searching on 'concrete5 single page multilingual' ... So i'll share my solution.

On the page_not_found.php in the theme I placed language dependent areas (which is probably not the best way, but it works).

<?php
$cPage = Page::getCurrentPage();
$lang = Localization::activeLanguage();
?>
<?php
   if($lang == 'en' || $cPage->isEditMode()){
      //main content
      $a = new Area('Main English');
      $a->setAreaGridMaximumColumns(12);
      $a->display($c);
    }
?>
<?php
   if($lang == 'fr' || $cPage->isEditMode()){
       //main content


This enables an admin to go into edit mode in the page_not_found page and at language specific blocks to the areas.

When a user goes to <url> / <lang> / <something that does not exists>, it will see the error message in the area of the <lang> .

The autonav in a global area is not displayed on the page_not_found single page. Other blocks in global areas are displayed, however usually in the first/initial language even if the <lang> is in the URL.
mlocati replied on at Permalink Reply
mlocati
In version 8 things are even more easier:

- add a stack to the page (or use a global area)
- stacks and global areas can now have a language-specific versions (see the Dashbard page "Stacks & Blocks" > "Stacks & Global Areas")

The page should automatically display the localized version accordingly to the user language.
TheRealSean replied on at Permalink Reply
TheRealSean
This does not appear to work any more (8.2.0) :(

I've added a stack to the page_not_found.php but only the default version is displayed.
guyasyou replied on at Permalink Reply
guyasyou
I have this problem too (8.2.1)