Language detection
Permalink
Hi,
I'm making my first 5.7 C5 site, so I'm still a bit lost on the new way of doing things.
I used to use this for redirecting to the current language homepage:
And this to change things based on language.
How can I go and to these things in 5.7?
Thank you
I'm making my first 5.7 C5 site, so I'm still a bit lost on the new way of doing things.
I used to use this for redirecting to the current language homepage:
$home = DIR_REL; if ( Package::getByHandle('multilingual') ) { $ms = MultilingualSection::getCurrentSection(); if (is_object($ms)) { $home = Loader::helper('navigation')->getLinkToCollection($ms, true); } }
And this to change things based on language.
$lh = Loader::helper('section', 'multilingual'); $lang = $lh->getLanguage(); if ($lang == "pt_PT"){ // Do stuff in PT } else { // Do stuff not in PT }
How can I go and to these things in 5.7?
Thank you
Hi Steevb,
Did you create the content areas under the main Home parent item in the sitemap? Like this:
Home -> fr -> en etc etc
Did you create the content areas under the main Home parent item in the sitemap? Like this:
Home -> fr -> en etc etc
See attached.
oh right okay. That makes much sense now
To retrieve the language associated to a page (let's call it $c):
If you want work with the current page, replace the first line above with:
If you want work with the current page, replace the first line above with:
$ms = \Concrete\Core\Multilingual\Page\Section\Section::getCurrentSection();
Thank you, exactly what I wanted!
See attached.
If you have a link I'll see if works at my end.