Copied to clipboard

Flag this post as spam?

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


  • Marc 50 posts 182 karma points
    Dec 01, 2020 @ 12:19
    Marc
    0

    Current document child

    Hello !

    I'm trying to get a value of a child element on the current page.

    I'm trying to do this way :

    @inherits Umbraco.Web.Mvc.UmbracoViewPage
    @using ContentModels = Umbraco.Web.PublishedModels
    @using Umbraco.Web.Models;
    
    @{
    
        var items = Model.ChildrenOfType("realisation").Where(x => x.IsVisible()).OrderByDescending(x => x.CreateDate);
    
        <div class="container margin-small">
                <div class="row">
                    @foreach (ContentModels.Realisation item in items.Skip((page - 1) * pageSize).Take(pageSize))
                    {
                       <div class="col-12 col-md-4 d-flex">
                           <a class="events-listing-link flex-fill" href="@item.Url">
                               <h4 class="events-listing-title">@item.RealisationTitle</h4>
                            <p>test</p>
                            <div class="flexible"></div>
                            <div class="events-listing-date text-center">
                                <p>test</p>
                            </div>
                            <div class="button-2 text-center">
                                <p>En savoir plus</p>
                            </div>
                           </a>
                       </div>
                    }
                </div>
            </div>
    }
    

    I don't know why I'm getting an error :

    CS1061: 'Realisation' does not contain a definition for 'RealisationTitle' and no accessible extension method 'RealisationTitle' accepting a first argument of type 'Realisation' could be found (are you missing a using directive or an assembly reference?)

    What am i doing wrong ?

    Thank you :)

  • Huw Reddick 335 posts 1007 karma points
    Dec 01, 2020 @ 14:18
    Huw Reddick
    100

    try @item.Value("realisationTitle");

  • Marc 50 posts 182 karma points
    Dec 01, 2020 @ 15:07
    Marc
    0

    Damn that was the same mistake as you pointed out on other of my topic. It's working.

    I don't understand why when I put Umbraco.Content, this @item.RealisationTitle works. And why I put Model.Chirldren it doesn't.

    Thank you again :p I will probably come again soom for some questions about multilingual selector ahah

  • Huw Reddick 335 posts 1007 karma points
    Dec 01, 2020 @ 16:47
    Huw Reddick
    0

    I think it is the way it is retrieved, so for children which is a collection of ipublishedcontent so you need to use Value (I think, but I'm quite new to this too :) )

  • 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