Copied to clipboard

Flag this post as spam?

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


  • HC Saustrup 28 posts 79 karma points
    Mar 09, 2012 @ 11:37
    HC Saustrup
    0

    Umbraco 5.0 - Proper way to check if a node is deleted

    Hi!

    I'm iterating through a list of articles with an optional author associated with a Content Picker. Some authors have been deleted from the content tree, but they are still referenced in the articles while they are in the Recycle Bin. Since they are no longer published, referencing article.Url will throw an exception. After emptying the Recycle Bin, the Content Picker reference changes to "Unknown" (not empty/undefined?), and I get another exception.

    What is the proper way to check if a node set with a Content Picker is either in the Recycle Bin or completely deleted?

    Below is a simplified example of my code:

    foreach (var article in articles)
    {
    var author = Umbraco.GetDynamicContentById(article.author);
    @if (author != null) {
    <li><a href="@author.Url">@author.Name</a></li>
    }
    }
Please Sign in or register to post replies

Write your reply to:

Draft