Copied to clipboard

Flag this post as spam?

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


  • Bas Schouten 135 posts 233 karma points
    Feb 18, 2016 @ 09:03
    Bas Schouten
    0

    MultiNodeTreePicker check deleted nodes

    I use the MultiNodeTreePicker for picking related content.

    When a node is deleted with is in use by te MultiNodeTreePicker my razor code gets an error.

    Is is possible to check if a node exists?

    @if(@CurrentPage.HasValue("related"))
    
    {
        <ul> 
            @foreach (var item in @CurrentPage.related.ToString().Split(','))
            {
            var page = Umbraco.TypedContent(item);
    
    
    
                <li>
                    <a href="@page.Url">
                        @page.Name
                    </a>
                </li>   
    
    
            }
        </ul>
    }
    
  • Kasper Holm 47 posts 180 karma points
    Feb 18, 2016 @ 09:09
    Kasper Holm
    100

    Hello Bas

    this should work :)

    @if(@CurrentPage.HasValue("related"))
    {
    <ul> 
        @foreach (var item in @CurrentPage.related.ToString().Split(','))
        {
        var page = Umbraco.TypedContent(item);
    
    
              if(page != null){
              <li>
                <a href="@page.Url">
                     @page.Name
                </a>
            </li>   
        }
        }
    </ul>
    

    }

  • Bas Schouten 135 posts 233 karma points
    Feb 18, 2016 @ 09:14
    Bas Schouten
    0

    Thanks Kasper! This works!

Please Sign in or register to post replies

Write your reply to:

Draft