Copied to clipboard

Flag this post as spam?

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


  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Nov 12, 2016 @ 09:21
    Michaël Vanbrabandt
    0

    Value is always null

    Hi,

    working with the Nested content for the first time and its realy nice.

    Easy to setup but when I want to get the value in my view its always null. When I use the debugger of visual studio I can see that the value is null but my DataValue contains the data.

    Am I missing something?

    Below is my code:

    @{ 
    
        var companyRepo = Model.Content.AncestorOrSelf(1).Children.Where(c => c.IsVisible() && c.DocumentTypeAlias == "companyRepo").First();
        var companies = companyRepo.Children.Where(c => c.IsVisible());
    
        if(companies.Any())
        {
            <ul>
                @foreach(var company in companies)
                {
                    var packages = company.GetPropertyValue<IEnumerable<IPublishedContent>>("packages"); // Nested content property
    
                    <li>@company.Name</li>
                }
            </ul>
        }
    
    }
    

    /Michaël

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Nov 12, 2016 @ 10:00
    Michaël Vanbrabandt
    0

    Ok something weird is going on.

    If I restart my website, the value is correct. Why is this?

    If I add a new item to my nested content, then its not automatically visible in the view. If I restart the app, then voila its there.

    Anyone?

    /Michaël

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Nov 12, 2016 @ 12:33
    Michaël Vanbrabandt
    100

    Ok I was using the ContentFinder where I used caching to store the values. After removing this, it works.

    Caching was set to one day, maybe in the live environment I will set this to 10 minutes or something like that.

    /Michaël

Please Sign in or register to post replies

Write your reply to:

Draft