Closed thfontaine closed 9 years ago
Hey Thibault, glad you like it =)
As for looping through the URLs of the current page translations, you can use the plugin alias function, which is a superset of the framework's own alias function, taking one extra $lang
parameter.
In the demo, it is basically achieved like this:
$f3=Base::instance();
$ml=Multilang::instance();
foreach($ml->languages as $lang)
echo $ml->alias($f3->ALIAS,NULL,$lang);//<-- translated page path
As you can see, the 2nd parameter is null, because the demo routes don't hold any dynamic token.
If you have dynamic tokens, you need to fill in the 2nd parameter. And the way to go depends on your app's architecture:
/en/area/web
and /fr/zone/web
share a common language-independant web
token), then just use $f3->PARAMS
as a 2nd parameter, as it holds the current language parameters./en/blog/8/hey-dude
and /fr/blog/8/salut-gros
are translations of the same page identified by the token id=8
), then you can also use $f3->PARAMS
as your app will naturally performs appropriate redirections (/fr/blog/8/hey-dude
=> /fr/blog/8/salut-gros
).Hope it makes sense ^^
Hey Florent, Thank you for your very clear answer. It works like a charm ! :+1: Your work is very appreciated.
Hey, I've seen your great demo of the plug-in, but I'm wondering how you dynamically build links to change the language while staying on the same page (the flags on top of the page). What I mean is if I'm on the /en/contact/ page, how can I make a /fr/contact link on the template ? Thanks in advance for your answer =)