Copied to clipboard

Flag this post as spam?

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


  • suzyb 474 posts 932 karma points
    Sep 20, 2013 @ 12:17
    suzyb
    0

    Getting first node with empty xml property

    I'm using the embedded content data type for a list of links on my pages.  Even when no items have been added for the property the data type still sets the value to <data /> which means I can't use the built in recursion doesn't work properly.

    So I'm trying to do something like this but it's returning 0 where it should be returning the home node.

    var quickLinkPage = Model.Content.AncestorsOrSelf().Where("quickLinks != \"<data />\"");

    I've also tried this, which I'm not entirely sure is valid but I don't get any error.

    var quickLinkPage = Model.Content.AncestorOrSelf().Where("quickLinks != \"<data />\"");

    No doubt I'm missing something simple but I can't think what.

  • suzyb 474 posts 932 karma points
    Sep 23, 2013 @ 11:36
    suzyb
    0

    Worked out how to do it.

    IPublishedContent item = Model.Content.AncestorsOrSelf().Where(x => x.GetPropertyValue("quickLinks") != null && 
    x.GetPropertyValue("quickLinks") != string.Empty && x.GetPropertyValue<string>("quickLinks") != "<data />").Last();
    var quickLinks = new umbraco.MacroEngines.DynamicXml(item.GetPropertyValue<string>("quickLinks"));
Please Sign in or register to post replies

Write your reply to:

Draft