Copied to clipboard

Flag this post as spam?

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


  • Daniel Horn 319 posts 344 karma points
    Mar 13, 2011 @ 13:52
    Daniel Horn
    0

    Parent node link

    Hi

    I have this structure:

    - News

    -- 2011

    --- news 1

    --- news 2

    -- 2010

    --- news 4

    --- news 5

    -- 2009

     

    On my frontpage I show both news from 2011 and 2010 - so how do i point them into the different pages (2011 and 2010).

    So when you click on news 1 you go to the 2011 page and when you click on news 4 you go to the 2010 page?

    It's my url3 i need to change to point to the parent of those news items.

    Here's what i'm trying:

            <dl class="morenews">
               <dt><xsl:value-of select="$currentPage/ancestor-or-self::*[@isDoc]/flereNyhederOverskrift" /></dt>
              
                <xsl:for-each select="$currentPage/descendant-or-self::Nyhed [@isDoc]">
                  <xsl:sort select="nyhedsdato" order="descending"/>
                  <xsl:if test="position() &gt;3 and position() &lt;=6">
                    <xsl:variable name="url3" select="$currentPage/parent::*[@isDoc]/nyhed"/>
                    <xsl:variable name="url2" select="parent::node" />  
                    
                  <dd><href="{$url3}#{@urlName}">
                   <xsl:value-of select="titelLinie1"/></a></dd>
                      </xsl:if></xsl:for-each>
              
                       <dd class="allnews"><a>
                    <xsl:if test="$url1 != ''">  
                    <xsl:attribute name="href"><xsl:value-of select="umbraco.library:NiceUrl($url1)"/></xsl:attribute>
                    </xsl:if><xsl:value-of select="$currentPage/ancestor-or-self::*[@isDoc]/lsFlereNyhederLinkTekst" /></a></dd>
                   
                    </dl>
          </div>
  • Kim Andersen 1447 posts 2196 karma points MVP
    Mar 13, 2011 @ 14:13
    Kim Andersen
    1

    Hi Daniel

    If you want the $url3 to contain a link to the parent node try this:

    <xsl:variable name="url3" select="umbraco.library:NiceUrl($currentPage/../@id)"/>

    /Kim A

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

    Hi Daniel

    Perhpas you could also make sure that the link is always pointing to the second or third id in the @path attribute? (Or whatever place the id has in the path attribute).

    This attributes contains a comma seperated list of nodeid's that makes up the path to the current node.

    So by splitting the content of this attribute using umbraco.library:Split() you can always go to the correct id by writing something like...

    <xsl:variable name="parent" select="umbraco.library:Split(@path,',')/values/value[2]" />

    I hope this makes sense.

    /Jan

     

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 8x admin c-trib
    Mar 13, 2011 @ 22:59
    Chriztian Steinmeier
    2

     

    Hi Daniel,

     

    To get the url3 variable to point to the parent of the page you're currently at in the loop,

    you should use current() instead of $currentPage - but in this case you can just ditch the

    "$currentPage/" part. I *think* what you're aiming at is really something like Kim's suggestion,

    but not using $currentPage - so effectively:

    <xsl:variable name="url3" select="umbraco.library:NiceUrl(../@id)" />

    @Jan: Don't mess with the @path attribute - it's usually much better to use the ancestor-or-self:: axis to access those nodes.

    /Chriztian

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

    Hi Chriztian

    Yes of course - just meant as an alternative solution :-)

    /Jan

  • Kim Andersen 1447 posts 2196 karma points MVP
    Mar 14, 2011 @ 09:14
    Kim Andersen
    0

    Holy smokes! How did I not notice that we where inside a loop :P

    Yeah, of course you shouldn't use $currentPage then, but do like Chriztian says.

    /Kim A

  • Daniel Horn 319 posts 344 karma points
    Mar 14, 2011 @ 16:15
    Daniel Horn
    0

    Thanks guys - you rock ! :)

Please Sign in or register to post replies

Write your reply to:

Draft