Copied to clipboard

Flag this post as spam?

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


  • phil 16 posts 119 karma points
    Jan 09, 2019 @ 16:59
    phil
    0

    Accessing Sibling Properties

    Hi,

    Looking for some help in accessing siblings properties. I've get a variable with the sibling I need to access but on trying to get the property value it just returns null. In VS if I use a brake point it does show that the sibling is logged and it holds two properties. It just wont store the properties in my variable.

    In the code below if im in the correct node then i can get the document link but if I try access from the sibling no such look. What am i missing?

    Thanks

    Phil

      var documentLink = CurrentSection.HasProperty("documentLink") ? CurrentSection.GetPropertyValue<IPublishedContent>("documentLink") : null;
    
    var siblings = Model.Content.Siblings().FirstOrDefault(x => "footerLinks".InvariantEquals(x.DocumentTypeAlias));
    
    var siblingsDocumentLink = siblings.HasProperty("documentLink") ? CurrentSection.GetPropertyValue<IPublishedContent>("documentLink") : null;
    
  • Nik 1614 posts 7260 karma points MVP 7x c-trib
    Jan 10, 2019 @ 13:43
    Nik
    0

    Hey Phil,

    Just looking at your code, you are checking that the siblings variable has the property "documentLink", but you are then trying to retrieve it from CurrentSelection. Should that not be siblings instead?

    So this:

    var siblingsDocumentLink = siblings.HasProperty("documentLink") ? siblings.GetPropertyValue<IPublishedContent>("documentLink") : null;
    

    instead of this:

    var siblingsDocumentLink = siblings.HasProperty("documentLink") ? CurrentSection.GetPropertyValue<IPublishedContent>("documentLink") : null;
    

    Nik

Please Sign in or register to post replies

Write your reply to:

Draft