Copied to clipboard

Flag this post as spam?

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


  • Fuji Kusaka 2203 posts 4220 karma points
    Dec 19, 2012 @ 21:15
    Fuji Kusaka
    0

    CurrentPage isAncestorOrSelf

    How do i get to check if the currentPage am on is an Ancestor of a specified RootNode ?

     

    var Node = @Model.NodeById(1047);
    var Home = Node.AncestorOrSelf();
    if(@Model.IsAncestorOrSelf(Node)){
    @Home.Name
    }
    else{
    @:nothing
    }

     

  • Rob 43 posts 79 karma points
    Dec 19, 2012 @ 23:31
    Rob
    0

    the root is level 1

    if you choose @CurrentPage.AncestorOrSelf(2) i think you should end up at the page just below Home. (assuming that Home is the "root" of the site and everything is below that.

    Also you could just look at the Level of the current node if all you want is to know if you are at the root.

    Rob

  • Fuji Kusaka 2203 posts 4220 karma points
    Dec 20, 2012 @ 06:37
    Fuji Kusaka
    100

    Hi Rob,

    Yes the root is level one but what am trying to do here is to check if for example a i have a multilingual website where i need to change the sequence of the sentence so i would like to check if my current node is an ancestor of whatever language root node assuming all of them are on level 1.

    Did something similar in xslt

      <xsl:when test="$currentPage/ancestor-or-self::*[@id=1000]">
Please Sign in or register to post replies

Write your reply to:

Draft