Ideas / suggestions for a page list template that changes the pages according to the current language.

Permalink
I'm creating a multi-language site with some global areas that contain page list element.
I needed to change to listed pages according to the current language, but didn't want to create different global area's for every language. (latest concrete5.6 btw)

So I added the following edits into a page list view.php:

<?php  foreach ($pages as $page):
        // =======================================
        // = Change page to appropriate language =
        // =(the following 4 lines are my edits ===========
        $ms = MultilingualSection::getCurrentSection();
        $newpage = Loader::helper('translated_pages', 'multilingual')->getTranslatedPages($page);
        $targetLang = $ms ->msLocale;
        $page = $newpage[$targetLang];
      // Prepare data for each page being listed...
      $title = $th->entities($page->getCollectionName());
      $url = $nh->getLinkToCollection($page);


It works, but It's slow. Suddenly the server takes many more seconds per page view (when cache is not enabled).

Does someone know a better way to accomplish this?

Jaakko
 
WebcentricLtd replied on at Permalink Reply
could you add an extra parameter to your helper for the locale rather than the way you're doing it?
Jaakko replied on at Permalink Reply
Jaakko
Thanks! I have to try that.
NickKN replied on at Permalink Reply
I have a similar issue
My solution was to create two stacks - one for English and one for French and then display them thus
[code] if($locale == 'en'){
$a = new GlobalArea('Side Pagelist en');
$a->display();
}
else if($locale == 'fr'){
$a = new GlobalArea('Side Pagelist fr');
$a->display();
}
{/code]
I don't know if this would give you what you want - I don't think you will have a time penalty though.
TheRealSean replied on at Permalink Reply
TheRealSean
I would like to know if its possible to get the language root page from the localization, that way we should be able to pass through a filter to the page lists similar to the filter by page option that is currently provided.

Ie Show all blog posts under the language page, (/en/)

Now if I could only work out how to get the language root cID?