Copied to clipboard

Flag this post as spam?

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


  • mmmoustache 50 posts 79 karma points
    Feb 27, 2012 @ 10:38
    mmmoustache
    0

    Display data from a page directly onto it's grandparent, using Razor

    Hi All,

    In short, I want to display data from a page onto it's grandparent, using Razor.

    In long, I have a section with three levels, the grandparent, parent and child node. On the child node I have several text string properties that I want to display on both of it's ancestors, but due to the site structure I need to be able to pull in the info directly onto the grandparent. The bottom level has it's own doctype which I'm sure will help things, and I'm fairly sure I can use DescendantOrSelf somehow, but I'm unsure of the correct method.

    Kind Regards

  • Rodion Novoselov 694 posts 859 karma points
    Feb 27, 2012 @ 14:04
    Rodion Novoselov
    0

    Hi. I think in Razor it can look like:

    var gchildren = CurrentModel.Descendants(dn => dn.Level == CurrentModel.Level + 2);

    or:

    var gchildren = Model.Descendants().Where("Level = @0", Model.Level + 2);

    depending on what syntax you prefer - strongly-typed or dynamic.

     

  • mmmoustache 50 posts 79 karma points
    Feb 28, 2012 @ 10:10
    mmmoustache
    0

    Ah, thank you! The second option worked perfectly for me!

Please Sign in or register to post replies

Write your reply to:

Draft