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
    Jan 31, 2015 @ 21:01
    Michaël Vanbrabandt
    0

    Partial view issue getting Node by DocumentType

    Hi,

    I am trying to do something simple but I just can't get it to work. I am trying to get the first 3 services I added in my content using following macro:

    @{
        var services = Umbraco.ContentAtRoot().DescendantsOrSelf("ServicesList").FirstOrDefault();
    }
    <div class="row">
        @foreach (var service in services.Children.Where("Visible").Take(3))
        {
            <div class="col-md-4">
                <div class="service-item">
                    <div class="icon"><i class="fa fa-@service.Icon"></i></div>
                    <h2 class="title">@service.Title</h2>
                    <div class="content">
                        @service.Content
                    </div>
                    <p class="links"><a class="button" href="#">@service.Title<i class="fa fa-long-arrow-right"></i></a></p>
                </div>
            </div>
        }
    </div>
    

    This macro is added at the home page.

    My Content structure:

    Homepage
    -- Services ( DocumentType: ServicesList )
    ---- Service 1
    ---- Service 2
    ---- Service 3
    ---- Service 4
    ---- Service 5
    

    For some reasing he just can't find the Services node...

    What am I doing wrong?

    /Michael

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Jan 31, 2015 @ 21:17
    Michaël Vanbrabandt
    100

    Ok I have found the solution, I looked into the database and saw that for DocumentType ServicesList the alias Serviceslist was. So the uppercase L of List was lowercase.

    This is confusing...

    So for querying you have to use the alias?

    /Michael

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies