Copied to clipboard

Flag this post as spam?

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


  • Mladen Macanovic 22 posts 45 karma points
    Nov 15, 2010 @ 12:36
    Mladen Macanovic
    0

    get parent node

    I have a multilanguage site with the following structure

    =============================

    mysite

    -hr

    --page 1

    ---sub page 1

    --page 2

    ---sub page 2

    -en

    --page 1

    ---sub page 1

    --page 2

    ---sub page 2

    =============================

    what I need to do is to select hr or en node depending on what page I'm currently on.

    I tried to use

    <xsl:value-of select="$currentPage/ancestor-or-self::node [@level=1]/node/@nodeName" />

    but that always return me the first node and in this case it is the hr node. How can I select en when I'm in the pages bellow it?

  • Rich Green 2246 posts 4008 karma points
    Nov 15, 2010 @ 12:41
    Rich Green
    0

    Which version of Umbraco are you using?

  • Mladen Macanovic 22 posts 45 karma points
    Nov 15, 2010 @ 12:42
    Mladen Macanovic
    0

    I'm using version 4.5.1.

  • dandrayne 1138 posts 2262 karma points
    Nov 15, 2010 @ 12:43
    dandrayne
    1

    Hows about

    <xsl:value-of select="$currentPage/ancestor-or-self::node [@nodeTypeAlias='yourHomepageAlias']" />

    Or in the new schema (4.5 +)

    <xsl:value-of select="$currentPage/ancestor-or-self::yourHomepageAlias[@isDoc]" />

    Dan

  • Chriztian Steinmeier 2798 posts 8787 karma points MVP 7x admin c-trib
    Nov 15, 2010 @ 12:45
    Chriztian Steinmeier
    1

    Hi Mladen,

    If your Content has the hr/en nodes at level 2 then you should stop at level 2 when walking the ancestor axis:

    <xsl:value-of select="$currentPage/ancestor-or-self::*[@level = 2]/@nodeName" />

    (This will work with both the "old" and the "new" Schema)

    /Chriztian

  • Rich Green 2246 posts 4008 karma points
    Nov 15, 2010 @ 12:46
    Rich Green
    0

    Not tested as converted from pre 4.5 code but should work

    <!--Get root of site regardless of where you are in site)
    <xsl:variable name="currentRoot" select="$currentPage/ancestor-or-self::root"/>

    Rich

  • Mladen Macanovic 22 posts 45 karma points
    Nov 15, 2010 @ 12:48
    Mladen Macanovic
    0

    Thanks Ckriztian, your solution worked like a charm.

Please Sign in or register to post replies

Write your reply to:

Draft