Copied to clipboard

Flag this post as spam?

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


  • Benoit Cornette 29 posts 169 karma points
    Nov 03, 2017 @ 15:45
    Benoit Cornette
    0

    Calendar

    Hi,

    For my client I have to make a calender where he can add/delete/modify and read events. You can have multiple events on one day and there has to be a title of the event, a location and a time (properties). Any experience with this?

    Kind regards,

    Benoit

  • Alex Skrypnyk 6150 posts 24110 karma points MVP 8x admin c-trib
    Nov 03, 2017 @ 15:51
    Alex Skrypnyk
    0

    Hi Benoit

    Is it what are you looking for - https://our.umbraco.org/projects/backoffice-extensions/eventcalendar/?

    Thanks,

    Alex

  • Benoit Cornette 29 posts 169 karma points
    Nov 03, 2017 @ 15:54
    Benoit Cornette
    0

    Hi Alex,

    Seems to be what I'm looking for but it's not for free... Any other suggestions?

    Kind regards,

    Benoit

  • David Parr 48 posts 206 karma points
    Nov 03, 2017 @ 17:20
    David Parr
    0

    I haven't tried this myself but how about this one;

    https://github.com/Mantus667/EventCalendarBelle

    Thanks

  • John Bergman 483 posts 1132 karma points
    Nov 03, 2017 @ 18:41
    John Bergman
    0

    They are the same (ie, the backoffice extension above and the GitHub project); has the licensing changed?

  • Amir Khan 1284 posts 2741 karma points
    Nov 03, 2017 @ 19:18
    Amir Khan
    103

    Hi Benoit,

    What we do is create a new document type for the events and add some fields (screenshot attached), we create a folder document type for this where all of the events will live and then on the template for that folder we drop in this: https://fullcalendar.io/

    We also create a view that renders the JSON to populate the fullcalendar plugin.

    You have tons of control over what fields you want, whether you want a map datatype on there, etc. Makes it super easy to customize.

    Here's a template for the JSON

    @foreach(var page in selection){                
       if(page.IsLast()){
                    var news = new {
                        title = @page.eventTitle,
                        start = @page.startDateAndTime.ToString("yyyy-MM-ddTHH:mm"),
                        end = @page.endDateAndTime.ToString("yyyy-MM-ddTHH:mm"),
                        url = @page.Url
                    };
    
                    @Html.Raw(Json.Encode(news))
                } else {
                    var news = new {
                        title = @page.eventTitle,
                        start = @page.startDateAndTime.ToString("yyyy-MM-ddTHH:mm"),
                        end = @page.endDateAndTime.ToString("yyyy-MM-ddTHH:mm"),
                        url = @page.Url
                    };
    
                    @Html.Raw(Json.Encode(news) + ",")
                }
     }   
    ]
    

    Hope this helps!

    Amir

    enter image description here

  • Eric McDonald 16 posts 137 karma points
    Apr 02, 2019 @ 23:44
    Eric McDonald
    0

    Hi Amir,

    I am trying to do something similar like your example above however I dont seem to understand how the JSON from the pages get added to the calendar.

    I have created a Document Type for the Calendar Events.

    I have created a Document Type for a page to display the Calendar, and I have added the Events document type as a child item.

    I have created a partial view to fetch all the child events from my Calendar page but I'm now stuck on how to get that data to display in the calendar. Any help you could provide would be appreciated.

    Here is my partial view code

        @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    
    @{
        var selection = Umbraco.TypedContent(1344).Children("booking")
                            .Where(x => x.IsVisible());
    }
    
    @foreach (var item in selection)
    {
        var startDate = item.GetPropertyValue<DateTime>("bookingStartDate");
        var endDate = item.GetPropertyValue<DateTime>("bookingEndDate");
    
        if (item.IsLast())
        {
            var booking = new
            {
                title = "Unavailable",
                start = startDate.ToString("dd,MM,yyyy"),
                end = endDate.ToString("dd,MM,yyyy")
            };
    
            @Html.Raw(Json.Encode(booking))
        }
        else
        {
            var booking = new
            {
                title = "Unavailable",
                start = startDate.ToString("dd,MM,yyyy"),
                end = endDate.ToString("dd,MM,yyyy")
            };
    
            @Html.Raw(Json.Encode(booking) + ",")
        }
    
    }
    

    Kind Regards Eric

  • thao-arthaus 2 posts 22 karma points
    Jan 20, 2020 @ 17:30
    thao-arthaus
    0

    Have you found the solution for this? Could you please advise me?

  • Eric McDonald 16 posts 137 karma points
    Jan 27, 2020 @ 22:15
    Eric McDonald
    0

    Hi Thao,

    Please see below the code I finally got working. Hope it helps

    First up is the partial view to return the events in the calendar on my main Availability page.

        @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    
    @{
        var selection = Umbraco.TypedContent(1344).Children("booking")
                            .Where(x => x.IsVisible());
        var booking = new List<object>();
    }
    
    @foreach (var item in selection)
    {
        var startDate = item.GetPropertyValue<DateTime>("bookingStartDate");
        var endDate = item.GetPropertyValue<DateTime>("bookingEndDate");
    
        if (item.IsLast())
        {
            booking.Add( new
            {
                title = "Unavailable",
                start = startDate.ToString("dd,MM,yyyy"),
                end = endDate.ToString("dd,MM,yyyy")
            });
        }
    
        else
        {
            booking.Add(new
            {
                title = "Unavailable",
                start = startDate.ToString("dd,MM,yyyy"),
                end = endDate.ToString("dd,MM,yyyy")
            });
        }
    
    }
    @Html.Raw(Json.Encode(booking))
    

    And on the Availability page I add this code

    @using System.Web.Script.Serialization;
    @using Newtonsoft.Json;
    @{
        Layout = "Master.cshtml";
    }
    
    @{
        var selection = Umbraco.TypedContent(1344).Children("booking")
                            .Where(x => x.IsVisible());
        var booking = new List<object>();
    }
    
    @foreach (var item in selection)
    {
        var startDate = item.GetPropertyValue<DateTime>("bookingStartDate");
        var endDate = item.GetPropertyValue<DateTime>("bookingEndDate");
    
        if (item.IsLast())
        {
            booking.Add(new
            {
                title = "Unavailable",
                start = startDate.ToString("yyyy-MM-dd"),
                end = endDate.ToString("yyyy-MM-dd"),
                color = "red",
                textColor = "white",
                eventBackgroundColor = "#FF0000"
            });
        }
    
        else
        {
            booking.Add(new
            {
                title = "Unavailable",
                start = startDate.ToString("yyyy-MM-dd"),
                end = endDate.ToString("yyyy-MM-dd"),
                color = "red",
                textColor = "white",
                eventBackgroundColor = "#FF0000"
            });
        }
    
    }
    @{
        var serializer = new JsonSerializer();
        var stringwriter = new StringWriter();
        using (var writer = new JsonTextWriter(stringwriter))
        {
            writer.QuoteName = false;
            writer.QuoteChar = '\'';
            serializer.Serialize(writer, booking);
        }
        var json = stringwriter.ToString();
    }
    

    Finally I add the javascript at the bottom to create a listener amd display the dates that are unavailable.

    <script>
        document.addEventListener('DOMContentLoaded', function () {
            var calendarEl = document.getElementById('calendar');
            var calendar = new FullCalendar.Calendar(calendarEl, {
                plugins: ['dayGrid'],
                events: @Html.Raw(json)
            });
            calendar.render();
        });
    </script>
    

    If you want to see it in action please see the website I designed this for.

    BemersydeEstate.com by Arca Studios

  • Amir Khan 1284 posts 2741 karma points
    Jan 28, 2020 @ 21:45
    Amir Khan
    0

    Thank you for posting this!

  • Marcio Goularte 388 posts 1360 karma points
    Nov 03, 2017 @ 20:57
  • Benoit Cornette 29 posts 169 karma points
    Nov 04, 2017 @ 08:09
    Benoit Cornette
    0

    Thanks for the replies, I will check them out and let you know what's working. This calendar looks great in my opinion but I'll have to figure out how it's gonna work with Umbraco: http://w3widgets.com/responsive-calendar/

    Kind regards,

    Benoit

Please Sign in or register to post replies

Write your reply to:

Draft