Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • dominik 711 posts 733 karma points
    Jan 21, 2011 @ 14:34
    dominik
    0

    Relate more than 2 documents

    Hello

    I try to make a multilingual website (umbraco 4.5.2)

    My navigation structures is:

    - de
    >> products
    >> contact
    - en
    >> products
    >> contact
    - fr
     >> products
     >> contact

    Ive got searched for the following xslt script

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet
            version="1.0"
            xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
            xmlns:umbraco.library="urn:umbraco.library"
            exclude-result-prefixes="umbraco.library">

    <xsl:output method="xml" omit-xml-declaration="yes" />

    <xsl:param name="currentPage" />
    <xsl:variable name="currentLanguage" select="$currentPage/ancestor-or-self::node[@level = 1]/data[@alias = 'language']" />
    <xsl:variable name="relatedNode" select="umbraco.library:GetRelatedNodesAsXml($currentPage/@id)" />
    <xsl:template match="/">
        <form>  
            <select onchange="window.location = this.options[this.selectedIndex].value;">
                    <xsl:for-each select="$relatedNode/relations[relation]">
                            <xsl:attribute name="onchange">
                                    <xsl:text>window.location = '</xsl:text>
                                    <xsl:value-of select="umbraco.library:NiceUrl($relatedNode/relations/relation/node/@id)" />
                                    <xsl:text>'</xsl:text>
                            </xsl:attribute>
                    </xsl:for-each>

                  <xsl:for-each select="$currentPage/ancestor::root/*">
                    <option value="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="language"/></option>
              </xsl:for-each>  
            </select>
         </form>
    </xsl:template>

    </xsl:stylesheet>

    This generates a dropdown with 3 options for Germany, English and France

    If i change between 2 languages everything is working fine but how can i use a third language?


     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 21, 2011 @ 18:14
    Jan Skovgaard
    0

    Hi Dominik

    Don't you have three languages on the site already? Is there one of the listed languages it does not switch to? At a first glance of the code I think all you need to do is to just add the new language node in the content section?

    /Jan

  • dominik 711 posts 733 karma points
    Jan 22, 2011 @ 15:47
    dominik
    0

    Hi Jan,

    If I use two languages the user is able to switch from parent to child.

    But if i use a third language the user is not redirected to the correct child.

    An example

    The user is on

    - de
    >> products

    and clicks "france" he is not send to:

    - fr
    >> products

     

    So it works if there is only one relation with one child but not if there are two child notes.

     

  • dominik 711 posts 733 karma points
    Jan 26, 2011 @ 09:09
    dominik
    0

    Is there no possibilty to relate more than 2 languages?

    How can a multilingual site can be done with more than 2 languages?

    It is necessary that the user will stand on the site he is actual at the moment.

    Thanks

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Jan 26, 2011 @ 10:18
    Hendy Racher
    0

    Hi Dominik,

    I've not tried the code above, and these thoughts are off the top of my head, so I might be wildly wrong, but I'm guessing that the loop setting the "onchange" attribute for the <select> will only set the "onchange" to the last value in the loop ?

    Just a suggestion, but how about creating a RelationType for each language, and an event on copy that links the two document IDs with the RelationType of the language being copied to ? That way you know from the <select> what language you're swapping to, and can lookup the single related ID for that RelationType.

    Alternatively if using the default "relateDocumentOnCopy" RelationType, then I think you'll have to iterate though each Relation and check to see if it belongs to the path of the tree language being directed to ?

    Cheers,

    Hendy

  • dominik 711 posts 733 karma points
    Jan 26, 2011 @ 10:26
    dominik
    0

    This sounds good but i am new to umbraco and therefor it is very hard to make this modification.

    I used the relation manager to make a new relation.

    Perhaps you are able to tell me how I can add the Event and connect both relation types.

    Thanks

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies