0

I am using Umbraco CMS and facing a problem in accessing the Contact us page using the AncestorOrSelf method. I have tried to explain it by example.

- Content
    -- Home (level = 1)
       -- About Us (level = 2)
       -- Contact Us (level = 2)
       -- News Area (level = 2)
       -- News Item 1 (level = 3)
       -- News Item 2 (level = 3)
    -- Other Node (level = 1)

By using Model.Content.AncestorOrSelf(1) I am getting the Other Node (level = 1 as in example).

How could I get the contact us page which is under Home level?

Mike Brind
  • 28,238
  • 6
  • 56
  • 88
  • Thanks Mike for clarifying and formatting the content. I came to this site with hope that somebody will answer my query as i am new to Umbraco. but it seems that nobody heeds. still hope.... – parikshit verma Apr 18 '15 at 15:59

1 Answers1

0

AncestorOrSelf(level) will traverse upwards through the ancestors of the node you are querying from. It will stop at the first node it finds that matches the level specified in the parameter.

In your case that would mean that doing a AncestorOrSelf query from any of the level 2 or level 3 nodes would traverse upwards until it reaches the Home node. It should never reach the Other Node unless you are doing it from a child/descendant node below the Other Node.

If this is not the case - what is the current page when you are executing this query?

Claus
  • 1,975
  • 18
  • 24