Copied to clipboard

Flag this post as spam?

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


  • Tony Kiernan 278 posts 341 karma points
    Mar 16, 2011 @ 11:11
    Tony Kiernan
    0

    Syntax question: ancestor-or-self but not 'cousins'

    I'm using this to select links attributed to pages above my currentPage

    $currentPage/ancestor-or-self::Site//Link [@isDoc
    and umbraco.library:GetXmlNodeById(@parentID)/@level < $currentPage/@level
    ]" />

    I'm just wondering if there's a different way of putting the first line in that that would negate the necessity of the second? My problem being without the second if shows links from similar level nodes down a differenct branch of the tree

  • Scott Hugh Alexandar Petersen 349 posts 164 karma points
    Mar 16, 2011 @ 11:17
    Scott Hugh Alexandar Petersen
    0

    the thing is that you are using //Link this says everybody on my level including cousins. If you remove that then it will only take from currentPage branch and nothing else.

    scott

  • Scott Hugh Alexandar Petersen 349 posts 164 karma points
    Mar 16, 2011 @ 13:17
    Scott Hugh Alexandar Petersen
    0

    sorry I did not specify well enough

    instead of //Link then you should use /Link the double // says everybody beneath me and on all equal levels

    eg.:

    - root
      - site 1
        - link 1
      - site 2
        - link 2

    Url: root/site 1/
    //Link gives (link 1 and link 2)
    /Link gives ($currentPage branch link 1)

    Url: root/site 2/
    //Link gives (link 1 and link 2)
    /Link gives ($currentPage branch link 2)

  • Tony Kiernan 278 posts 341 karma points
    Mar 16, 2011 @ 13:40
    Tony Kiernan
    0

    I think I follow that.

    I want something like this

    - root
        - link 1
      - site 1
        - site 1 subpage
      - site 2
        - site 2 subpage
         - link 2

    When on site 1, site 1 subpage or site 2, link 1 will display

    On site 2 subpage only link 2 (this is handled by another select)

    Using

    $currentPage/ancestor-or-self::Site/Link [@isDoc]

    Shows link 1 only on root

Please Sign in or register to post replies

Write your reply to:

Draft