What is the most effective way toggle between multiple Home Pages / Sites? I am confused that they have the same page name / url. I have assigned them
fake subdomains as intructed elsewhere on the forum, but honestly I
don't see how this is going to do the trick.
I have a dropdown at
the top of the page that offers Spanish and English. How can I make
the users' choice select the correct home page and subpages?
A javascript powered dropdown is convenient and widely used (although not very accessible). If there are only two languages I usually just write out two standard links to the homepages of each language.
However, I do not have a field on this page for Language. I was instructed to do this using the Manage Hostnames dialog, where I then choose a language and a subdomain with which to associated the page/site. How do I dynamically get the assigned language from the node as described above? Because
I used a field on the document so I could have a human-readable language option. People didn't want to see "en-GB" or even "english - united kingdom", so I created a field to allow people to name the language, so we got:
Ok. Gotcha. Thanks again. Now, a couple of remaining issues:
How can I get the select box to "auto-select" based on which language was/is selected? I don't know how to perform this comparison in the XSLT. I mean, without hard-coding the subdomain(s). Any ideas?
Is there a way to modify the <xsl:for-each> in such a way that the URL in the <option> isn't ALWAYS the home page? In other words, when you change the language, it would stay ion the same page, just changing the subdomain. Eg., "http://fr.localhost/about.aspx" to "http://en.localhost/about.aspx". Any way?
I have an XSLT snippet that does both of your remaining issues, but it's using 'relations' (having created additional languages' sites by copying the entire structure from the base site and checking a checkbox for creating a relation between them). This way the URL of the two pages doesn't even have to be the same...
Anyway, maybe you can use some of it (as Dan, I have a 'language' property on the Homepage DocumentType):
This is fantastic, Chriztian! Thank you so much! However, I DO still have one problem-- the currentLanguage variable returns as English no matter what. In other words, the redirect is working great but even when I'm on the Spanish or French sites, "English" is selected. Any idea why this would be? My @language fields are definitely populated correctly.
Oh - remember to check the generated HTML source — another reason "English" would be selected regardless of actual language, could be that English is the first language, and that no options are explicitly selected... does the HTML actually contain <option selected="selected">English</option> ?
The answer, Chriztian, is that I AM NOT *IN* the site I THINK I am! I was told that if I set the subdomains and associate a language with them under the Manage Hostnames doalog, that Umbraco would take care of the rest in terms of separating the sites. Why, no matter what subdomain I am browsing, am I always looking at the same site? I tried changing some content in my Spanish site and I am on http://ES.localhost/, and my changes are not there. I am ALWAYS looking at the English site. What am I doing wrong here?
Yes, this was the reason-- good lookin' out :) That problem is a thing of the past. NOW-- glad I have you back, Chriztian, because I'm using your XSLT code snippet for toggling the language, and although it seems to be working great in Some places, I am getting somewhat inconsistent results from it. To refresh your memory, here's what we've got:
And so the toggle works-- the language is switched because of the inclusion of the subdomain. However, this first part of the URL is left out on 3rd-tier, and moreover, any nth-tier page greater than the 2nd level. Why is this? Can you please give me some advice on how to fix this in the XSLT?
I'm afraid I can't give you any great explanation here, because the culprit lies within the NiceUrl() method - as you can see, the actual URL is generated from the id of the related node — if you're curious about the XML returned from GetRelatedNodesAsXml(), it looks similar to this example:
toggling between languages
With regard to Multi-language sites,...
What is the most effective way toggle between multiple Home Pages / Sites? I am confused that they have the same page name / url. I have assigned them fake subdomains as intructed elsewhere on the forum, but honestly I don't see how this is going to do the trick.
I have a dropdown at the top of the page that offers Spanish and English. How can I make the users' choice select the correct home page and subpages?
Thanks again,
Garrett
A javascript powered dropdown is convenient and widely used (although not very accessible). If there are only two languages I usually just write out two standard links to the homepages of each language.
Like
then
(js is untested!)
Dan
Seems to make good sense. Thanks for that.
However, I do not have a field on this page for Language. I was instructed to do this using the Manage Hostnames dialog, where I then choose a language and a subdomain with which to associated the page/site. How do I dynamically get the assigned language from the node as described above? Because
isn't returning anything.
Thanks again,
Garrett
I used a field on the document so I could have a human-readable language option. People didn't want to see "en-GB" or even "english - united kingdom", so I created a field to allow people to name the language, so we got:
"English"
"Francais"
"US English"
etc.
Ok. Gotcha. Thanks again. Now, a couple of remaining issues:
I very appreciate your time, @dandrayne.
//Garrett
Hi Garett,
I have an XSLT snippet that does both of your remaining issues, but it's using 'relations' (having created additional languages' sites by copying the entire structure from the base site and checking a checkbox for creating a relation between them). This way the URL of the two pages doesn't even have to be the same...
Anyway, maybe you can use some of it (as Dan, I have a 'language' property on the Homepage DocumentType):
/Chriztian
This is fantastic, Chriztian! Thank you so much! However, I DO still have one problem-- the currentLanguage variable returns as English no matter what. In other words, the redirect is working great but even when I'm on the Spanish or French sites, "English" is selected. Any idea why this would be? My @language fields are definitely populated correctly.
Thanks,
Garrett
Hey Garrett,
'couple of possibilities for currentLanguage not changing:
(You could also look for a specific DocumentType instead of going to level 1, that was just easiest in my scenario)
/Chriztian
Oh - remember to check the generated HTML source — another reason "English" would be selected regardless of actual language, could be that English is the first language, and that no options are explicitly selected... does the HTML actually contain <option selected="selected">English</option> ?
/Chriztian
Yes. Below is my output:
I copied code exactly. What do you think is going on here?
Thanks in advance,
Garrett
The answer, Chriztian, is that I AM NOT *IN* the site I THINK I am! I was told that if I set the subdomains and associate a language with them under the Manage Hostnames doalog, that Umbraco would take care of the rest in terms of separating the sites. Why, no matter what subdomain I am browsing, am I always looking at the same site? I tried changing some content in my Spanish site and I am on http://ES.localhost/, and my changes are not there. I am ALWAYS looking at the English site. What am I doing wrong here?
//Garrett
Hi Garrett,
This was caused by the issue with top-level nodes being named the same, from this thread, right?
(Just making sure future Umbraco-Ninja-Padawans will find an explanation for this.)
/Chriztian
Yes, this was the reason-- good lookin' out :) That problem is a thing of the past. NOW-- glad I have you back, Chriztian, because I'm using your XSLT code snippet for toggling the language, and although it seems to be working great in Some places, I am getting somewhat inconsistent results from it. To refresh your memory, here's what we've got:
What's happening is that on 2nd-tier pages (eg., Home > About), it's writing out the FULL path in the onchange call, eg.:
And so the toggle works-- the language is switched because of the inclusion of the subdomain. However, this first part of the URL is left out on 3rd-tier, and moreover, any nth-tier page greater than the 2nd level. Why is this? Can you please give me some advice on how to fix this in the XSLT?
Thanks again,
Garrett
Hi again Garrett - we meet again :-)
I'm afraid I can't give you any great explanation here, because the culprit lies within the NiceUrl() method - as you can see, the actual URL is generated from the id of the related node — if you're curious about the XML returned from GetRelatedNodesAsXml(), it looks similar to this example:
Maybe someone closer to Core can shed some light on this peculiarity...
/Chriztian
Perhaps this issue is related to your niceUrl() problem with the 3rd level? Includes proposed workaround:
http://our.umbraco.org/forum/getting-started/installing-umbraco/6449-Umbraco-NiceUrls-not-returning-with-full-domain
cheers,
doug.
is working on a reply...