Copied to clipboard

Flag this post as spam?

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


  • Meghana Lokrey 5 posts 95 karma points
    May 11, 2020 @ 17:43
    Meghana Lokrey
    0

    Multi-Url Picker in V8.5

    Hi, I am in process of upgrading to version 8.

    I need the list of CalendarEvent (doctypealias: calendarEvent) under Calendar (doctypealias: calendar) node. On a page (doctyealias:CalendarListPage) has a multi-url picker Calendar (multi-urlproperty) and code grabs its Id. Based on the Id picks list of CalenderEvents

    This is what I have in 7.12.3. @inherits Umbraco.Web.Mvc.UmbracoTemplatePage

    @{ var calendarNode = Umbraco.Content(CurrentPage.calendar.Id);

    var calendarEvents = calendarNode.calendarEvents.Where("Visible").OrderBy("StartDateTime");
    

    }

    @foreach (var calendarEvent in calendarEvents) { code here }

    In version 8 I have @inherits Umbraco.Web.Mvc.UmbracoViewPage @{ var calendarNode = Model.Calendar.Id; var calendarEvents = calendarNode.CalendarEvents; }

    I get an error at CalendarEvents 'int' does not contain a definition of CalendarEvents

    Any insight helpful. -Meg

  • Nik 1614 posts 7260 karma points MVP 7x c-trib
    May 11, 2020 @ 20:43
    Nik
    0

    Hi Meg,

    I think you could try:

    @inherits UmbracoViewPage<CalendarListPage>
    
    @{
        var calendarNode = Model.Calendar;
        var calendarEvents = calendarNode.CalendarEvents;
    }
    

    See if that clears up your error.

    Thanks

    Nik

  • Meghana Lokrey 5 posts 95 karma points
    May 11, 2020 @ 21:11
    Meghana Lokrey
    0

    Hi Nik,

    It gives an error "IPublishedContent" does not contain a definition for "CalendarEvents"

    Thanks

  • Meghana Lokrey 5 posts 95 karma points
    May 12, 2020 @ 13:47
    Meghana Lokrey
    100

    I solved it.

    @inherits Umbraco.Web.Mvc.UmbracoViewPage

    @{ var calendarNode = Model.Calendar.Id; var calendarEvents = Umbraco.Content(calendarNode).ChildrenOfType("calendarEvent"); }

    @foreach (var calendarEvent in calendarEvents)
    {
    
        <div class="row">
    
            <div class="medium-10 small-8 columns">
    
                <h5>@calendarEvent.Name</h5>
                @Html.Raw(calendarEvent.Value("eventDescription"));
                @if (calendarEvent.HasValue("eventLinks"))
                {
                    <br />
                    var links = calendarEvent.Value<IEnumerable<Link>>("eventLinks");
                    foreach (var item in links)
                    {
    
                       // var linkUrl = (item.HasProperty("External")) ? item.Value("link") : item.Value("link");
    
                        <br /><a href="@item.Url" target="@item.Target">@item.Name</a>
                    }
                }
    
                <br />
                <br />
    
Please Sign in or register to post replies

Write your reply to:

Draft