ceberlin Posted September 2, 2013 Share Posted September 2, 2013 I have a very tricky problem.... My languages appear into separate trees and not in languagesfields within a page. Now: /en/page1 /en/page2 ... /es/page1 /es/page2 Now I need to separate languages in dialects as a tool to be able to address local content for countries on certain pages. Solution 1? /en-UK/page1 /en-UK/page1 /en-US/page1 /en-US/page1 ... /es/page1 /es/page2 This would be a technical clean solution - but editors would need to duplicate every change that is common for a language to all dialects pages. So this does not work. (All content is the same appart from a few exceptions) Solution 2? /en/UK/page1 /en/UK/page1 /en/US/page1 /en/US/page1 ... /es/page1 /es/page2 We thought of making /US/ and /UK/ are segments from the page /en/. A segment would make it possible to bookmark the dialect setting. There would be only a language tree /en/ and the dialect /UK/ would change the content slightly by the API, like returning a different support phone number. Is it possible to have a segment element in the middle of a path? Looks like it's not... Or is there a different way to archive this? Link to comment Share on other sites More sharing options...
Soma Posted September 2, 2013 Share Posted September 2, 2013 Good luck, we also have had projects in the past with lots of languages and en us version (not with PW) and it's a pain no matter what CMS. Often they don't really serve texts for each dialect specific, it's often just for a phone number or little text here and there. Annoying. Hard to decide what makes most sense without knowing the project in detail. Without thinking a lot maybe.. /en/page1/ /en/page2/ /es/page1/ /es/page2/ ..and have root home page urlSegments turned on. ..then construct your links /en-us/page1/ /en-us/page2/ /en-uk/page1/ /en-uk/page2/ /es/page1/ /es/page2/ if a url solves to a page that already exists PW will render the page itself, otherwise the path end up as urlsSegments in your home ( or urlSegmentsStr I think in 2.3.1 dev only) and in the home template have code to read urlsegments and load and render a specific page. /en-us/page1/ and /en-uk/page1/ mapping to /en/page1/ : if(count($input->urlSegments)){ // we have url segment(s) if($input->urlSegment1 == "en-us") { $input->setUrlSegment(1, "en"); $dialect = 'us'; } elseif($input->urlSegment1 == "en-uk"){ $input->setUrlSegment(1, "en"); $dialect = 'uk'; } $p = $pages->get("/".$input->urlSegmentStr."/"); // if url didn't resolve to a page show the 404 page if(!$p->id) throw new Wire404Exception(); // render the page and give it a $options['dialect'] echo $p->render(array('dialect' => $dialect)); } else { // output your home page ... } In page that are rendered this way will have the dialect set in $options['dialect'], which you could use to output different address or phone number. Maybe I'm missing something and written in the browser so take it with a grain of salt. Link to comment Share on other sites More sharing options...
ceberlin Posted September 6, 2013 Author Share Posted September 6, 2013 Hi Soma, thanks for your ideas. Yeah, really tricky. Right now I am trying to avoid this by using cookies and sessions to remember the country settings and let PW only handle the basic languages, as before. Maybe I have a use for segments on single pages that need to do special things , like the contact pages. I am curious how far I come with that. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now