Otherwise all of the values will be same as the current page :)
And hen the content of the options must be changed from this:
<xsl:value-of select="$currentPage/language"/>
to this:
<xsl:value-of select="language"/>
when you are inside a loop, and want to output anything unique from the nodes, you shall not use $currentPage. If you do so, there'll be output values from the current page where the for-each are being run at.
The problem with the Javascript is solved. It was rather trivial. I copied the Javascript code from Tim's blog, but apparantly the double quotes are not valid:
implementing language selector
Hi,
I am implementing the language selector solution that Tim Geyssen provided on his blog:
http://www.nibble.be/?p=32
The problem is that this code is still in the old schema:
I have already converted some code to the new schema:
<xsl:template match="/">
<form>
<select name="langselection" onchange="loadPage(this.form.elements[0])" target="_parent._top">
<option selected="selected">– Please select –</option>
<xsl:for-each select="$currentPage/ancestor::*">
<option value="{umbraco.library:NiceUrl($currentPage/@id)}">
<xsl:value-of select="$currentPage/language"/>
</option>
</xsl:for-each>
</select>
</form>
</xsl:template>
But I still have an issue with looping through the top level root nodes.
Currently my site structure looks like this:
en
page 1
page 2
page ...
nl
page 1
page 2
page ...
fr
page 1
page 2
page ...
With the above converted code though, I'm just getting one top level node: en
So I guess the line: <xsl:for-each select="$currentPage/ancestor::*">
does not loop through all my top level nodes.
How can I loop through all the top level nodes?
Thanks for your help,
Anthony Candaele
Belgium
Hi Anthony.
I haven't tried this language selector, but I guess that you need to change the for-each to this:
/Kim A
Ohh and by the way you might want to change the value of the option-tags from this:
to this:
Otherwise all of the values will be same as the current page :)
And hen the content of the options must be changed from this:
to this:
when you are inside a loop, and want to output anything unique from the nodes, you shall not use $currentPage. If you do so, there'll be output values from the current page where the for-each are being run at.
/Kim A
Hi Kim,
Thanks, now the language selector shows all options (English, Nederlands, Français) witht their respective values (/en.aspx, /nl.aspx and /fr.aspx).
The only thing that does not work seemingly is the Javascript file:
<script language=“JavaScript”>
function loadPage(list) {
location.href=list.options[list.selectedIndex].value }
</script>
If I select an option in the dropdownlist, nothing happens, I suppose there should be a page reload.
The html in my dropdownlist looks like this:
Thanks for helping me out,
Anthony Candaele
Belgium
The problem with the Javascript is solved. It was rather trivial. I copied the Javascript code from Tim's blog, but apparantly the double quotes are not valid:
<script language=“JavaScript”>
function loadPage(list) {
So I just replaced the invalid double quotes and now my language selector works perfectly :)
<script language="JavaScript">
Thanks for helping me out Kim,
Anthony
You are very welcome Anthony :)
/Kim A
one question
is it possible to jump to the nearest element if no translation is available
for example:
I got two languages english and german and my structure is like:
en/products/cars/car-one.aspx
but in german there is only:
de/products/cars/ available but not car-one.aspx?
The user should be redirected to the de/products/cars/ and not to the root directory like it is at the moment
Thanks
Can somebody please help?
is working on a reply...