How to Create a Calendar in Drupal 8

How to Create a Calendar in Drupal 8

Drupal 8 is still a very new system and many contributed modules are just starting to catch up.

However, there are some features already available in Drupal 8. The Calendar module is not bug-free and doesn’t have all the features it did on Drupal 7, but it is working on Drupal 8.

Here’s a guide to building your first Drupal 8 calendar.

Getting set up for the calendar

First, install the Drupal 8 versions of these two modules:

Now go to Structure > Content types and create a content type that uses the core Date field:

Finally, clear your site’s cache. You can do this via Configuration > Performance.

Creating the calendar

  • Go to Structure > Views.
  • Click “Add view from template”.

You’ll now see list of pre-existing templates that you can used to create calendars.

Because you created a Date field, there should be a template available for that field. I’ve highlighted the template for my example. Click “Add” next to this template.

  • Choose a “View Name”.
  • Choose a “Base View Path”. This will be the URL for your calendar.
  • Scroll down the preview area and you should see your new calendar:
  • Click “Save”.
  • Click “View Month”.

Visit the front of your site and you’ll see your new calendar!

Instructor

  • Steve is the founder of OSTraining. Originally from the UK, he now lives in Sarasota in the USA. Steve's work straddles the line between teaching and web development.

0 0 votes
Blog Rating
Subscribe
Notify of
50 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Eric

Really cool Tutorial.
Is there a possibility to have recurrent events. I want to build a training schedule, where I want to say, every Monday at a time there is this training. At an other page I want to display the current days Events. Is this already possible in D8 or is there a module?

steve

Good question. The core date module doesn’t support recurring dates at the moment.

jeffanthony

As a Google Apps for Work fan I’m using a Google Calendar iframe into particular content. Many functions like recurring schedule are supported.

steve

Thanks Jeff. Yes, that might be the best approach for people who want advanced calendars and to use Drupal 8 right now.

Paul Rijke

The way I did this is to add multiple dates to an event. So no repeat pattern but a manually set repeat dates. This will work for now

Conqueror

in D7 this was possible creating a content type with Date field and enabling the repeatable date option (which you can’t change after you once have entries in the DB)

steve

Yes. True. The Date module has been moved into the D8, but it lost a lot of features in the process.

Darren Forster

Is there a reason that D8 lost the repeatable date section because if D8 is a step forward surely removing that function is a major step backwards? and do they have any intention on getting round to implementing it. I only recently started with Drupal a few months ago, prior to that I’d used Joomla but then I started working for a company that was really mad on Drupal 7. I asked them why they didn’t use Drupal 8 seeing as it’s the latest and they said because of all the things missing. After developing a charity website in D8 I can certainly see what they’re meaning – daterange doesn’t work properly, no recurring events, no ecommerce – can’t understand how D8 has even made it past alpha stage with so many major important features missing – and Appnation keep advertising it – it’s no use advertising it if half of it doesn’t work. I might see if there is some way of implementing a recurring date – surely there is some php library out there that I could give it the date started and the recurring information and have it return the next date some function maybe like…
function nextRecur ( startdate, period, skip = 0, month_day = false , enddate = null )
then use period to decide whether to increment in days, weeks, months, years by skip number, month_day to determine if it’s set to months whether it should stick to the day of the month or the date and then enddate for the stop recurring date (or set to null if no end date, then it either returns the next date or null if recurrence has ended – surely something like this wouldn’t take too much to implement?

daniel-pickering

Hi, Darren,
The simple answer to the repeatable date question is that it made getting the calendar module out quicker.
I am sure drupalers have plans to reintroduce it.
For events there is an event module for D8 and for commerce I say personally that ubercart has worked for the last 7 months + reliably I have set it up on several sites. And commerce is now stable I haven’t worked with it but I hear good things about it.
As for implementation I can’t speak for others it really depends on the maintainers you can use console and composer now to bring in libraries and make your own modules very easily. So it is possible that most people use a bespoke setup rather than a generic one. I am sure the functionality will exist eventually. Part from the repeat date I think many of the features you talk about are covered and I would consider that many simply hook into google calendar for the repeat date functionally currently.
Daniel

Darren Forster

Thanks for the reply – it is just a bit frustrating when ever I keep going on drupal modules and I see a link that says this is not in Drupal 8 yet please click here to find out what the issues are, and your like oh but I want that functionality. I’ve now got a bit of a program that actually generates repeated dates using php’s DateInterval, it can even do things like the 1st Monday of every month (or the first monday of the month skipping ever x number of months – my main reason for implementing this was I go to an Asperger’s charity and we have meetings that go to the same pub every three months on the same day so I needed to make it that I could put in one initial date and then once that date is gone it could show the three months ahead of the next time we’re going that pub again). I’ve got it all nearly working which actually if I might even see if I can turn it into a module which would help grow Drupal further – I’ve created modules in the past for Joomla but that seemed a lot more easier to create modules for than Drupal – from what I gather to create modules for Drupal I need access to SSH to access DruSH (my host won’t give me SSH access) am I right? also the database in Drupal seems a lot more complex than the one in Joomla and I’ve just pieced my own implementation together using a combination of DisplaySuite and Field Collection – only slight problem I’ve come across is that Views won’t sort the repeated dates as it only seems to sort by the original date not the calculated date and the PHP sort module in views says that each data item is in !Link variables – which !Link doesn’t appear to be any type of variable.
Btw also thanks for letting me know that Ubercart works with D8 as that is one of the main reasons the company I work at keep refusing to go up to D8 for – there excuse is they won’t go to D8 because there is no ecommerce, but my thought though is that surely it’s better to use the later technology than the older stuff, it’s like people who refuse to embrace Windows 10 because their happy with Windows XP when actually your going to have to make the switch and the sooner you do so the better it will be, and even if the ecommerce package doesn’t work for what they use ecommerce for it could be quite easily implemented anyway without any ecommerce package as they’re only a small company and they don’t even have ecommerce at present, they just keep saying they like to keep to a system that could have it, in case we need it in the future – which actually in fact by the time we need it in the future it probably will be in Drupal 8 anyway!

daniel-pickering

‘I’ve got it all nearly working which actually if I might even see if I can turn it into a module which would help grow Drupal further’
You should definitely Try we have a tutorial on contributing to Drupal that I wrote if you are interested.
‘I’ve created modules in the past for Joomla but that seemed a lot more easier to create modules for than Drupal’
Yes you have to follow the modern coding standards they are very strict about it.
‘from what I gather to create modules for Drupal I need access to SSH to access DruSH (my host won’t give me SSH access) am I right?’
You have that a little backwards you need SSH between your machine and [url=http://drupal.org]drupal.org[/url] not between you and your host.
‘only slight problem I’ve come across is that Views won’t sort the repeated dates as it only seems to sort by the original date not the calculated date and the PHP sort module in views says that each data item is in !Link variables – which !Link doesn’t appear to be any type of variable.’
You might want to give better exposed filter module a try for better filtering.
Yeah the best way to go with small e commerce is to just use paypal with something. Ubercart commerce strip they all support this. Not sure on the strip status in D8 yet.
Hope that helps you a little.
Thanks,

Daniel

borsodas1

because this is a view can data be exported or imported via JSON?

David Dienhart

Excellent tutorial. Thanks so much for putting it together and breaking it down. This made getting a calendar setup in D8 very easy for me when I needed to get it up and running quickly.

Bret Lopes

Nice. very visual and detailed. However, I find Drupal 8 difficult to work with. 7 is much easier. I found a similar tutorial here: [url=http://westweb-solutions.com/blog/drupal-8-how-dispatch-event]http://westweb-solutions.co…[/url]. It’s simpler, yet complicated 🙂

Simone sous BRaümurr

Thanks for this great tut!

I would like to know how to set up a “start date” and a “end date” (2 fields in content type, as D8 doesn’t coolect an end date on Date field at the moment) on the calendar ?

Discuss

Nice tutorial. But there is an issue , which breaks the entire system. Once after creating the Event the calendar stops working. For this we need to clear the cache so that the calendar starts working. Error is “Error: Call to a member function getGranularity() on boolean in Drupal\calendar\CalendarHelper::getDisplayForGranularity() (line 853 of C:\WTServer\WWW\drupal8\modules\contrib\calendar\src\CalendarHelper.php) #0 “

daniel-pickering

Thanks for sharing the fix.
Daniel

Discuss

Hey Daniel,

Its just a temporary fix, Its throwing an error for every event that is created. It can be resolved by clearing the cache. But this is not the good way to do for each n every event that is created. we need to find out the better solution than this.

daniel-pickering

I would recreate the content type. I’ve just reproduced the steps in the guide and it didn’t happen for me.
Thanks

Daniel

Vale

Hi! Thanks a lot for the tutorial. I’m having an issue with the pager as it skips some months when clicking next (it goes like this: Jan, Mar, May, Jul, Aug, Oct, Dec and so on) and when clicking previous it stays at the current month (the url in the previous button is indeed the current month url). EDIT: Checking Calendar issues i have found this: [url=https://www.drupal.org/node/2737239]https://www.drupal.org/node…[/url]

Michael Sypes

Important Note, since it’s not clear from the above: This only works with regular dates, not date ranges

chegor

I did all from this tutorial but my calendar is empty. Should I do something additionally?

daniel-pickering

Hi Chegor,
And you have added some dates to your content type?
Daniel

chegor

I found that problem is available in the latest dev. I tried to use dev from May 2016 and all is ok in this old version of the module 🙂

steve

Thanks for reporting, chegor.

Hamish Kruse

Hi Steve, thanks for the tutorial, I’ve got my calendar up and running, but I cannot seem to add any content to it. Could you give a short example of how this might be done? I see that to another comment you said to add in dates, but i am unsure of how to do this.

Regards,

Hamish

steve

Hi Hamish
If you’re unsure how to add date fields, I’d really recommend you take some of the basic Drupal 8 classes: [url=http://ostraining.com/classes/drupal-8/]http://ostraining.com/class…[/url]. Without that fundamental knowledge, you’ll be lost trying to use a calendar.

Hamish Kruse

Thanks Steve, that is exactly the kind of resource I have been looking for!

daniel-pickering

Hi Hamish,
We also provide support via [url=http://ostraining.com]ostraining.com[/url] so if you need help we are just a message away.
Thanks

Daniel

Juan Pablo Martínez

Hi, I am trying to make it work with existing content types (article) but I am not able to get work. Am I missing something? Thanks.

steve

Hi Juan
You would need to give us some more detail for this. Did you follow everything clearly and check that the logs don’t show any errors?

Juan Pablo Martínez

Hi, Steve. If I try creating “Events” content type, everything works perfect, but if I adapt an existing content type to act as an event, I got the following error: Warning: Invalid argument supplied for foreach() in Drupal\calendar\Plugin\views\style\Calendar->render() (line 539 of modules/calendar/src/Plugin/views/style/Calendar.php). I think that the calendar module is not prepared to work with existing conten types like the articles. BTW, I added core date field to the article and then I followed all the steps to make it work but i haven’s suceeded.

Juan Pablo Martínez

The problem is that you should create the input field with field_event_date name. If ypu choose another, then it breaks.

steve

Thanks for Sharing Juan.

King Shaumbra

Is it possible to add events using the calendar in drupal 8. I’m looking to allow an internal user to add event details by checking the events within calendar. Appreciate any help with this.
Thank You

Ricky Ramirez

Hi, this was fun to do (with analyzing and conducting). I performed this tutorial multiple times. Each time I conduct the experiment, I receive the same results (calendar not working). In contextual filters I receive a Broken/missing handler. I also receive an error relating to the issue, stating the following
\Drupal\calendar\Plugin\views\style\CalendarStyle: A calendar date argument is required when using the calendar style, but it is missing or is not using the default date.
I will conduct another try. However, my hypothesis is that Calendar is not supported by Drupal 8, which is why there is no official workable module just a dev version. Therefore Calendar does not work on Drupal 8.0. If anyone can complete this and disapprove my hypothesis, feel free.
Below is a source of other individuals having the same issue.

[url=https://www.drupal.org/node/2492011]https://www.drupal.org/node…[/url]
Thank you,

craig peddie

I have my calendar created and events are showing up on it. However, even though the date is correct in the event detail, on the calendar the events are all shown to be one day later than the actual date I’ve entered. Is there a fix for this? Or some configuration I need to change?
Thanks….

Roy Wagner

(D8 site) I have noticed that if I inadvertently give an event a 9pm time, rather than 9am as intended, it shows up on the next day along with a horizontal rule under the entry. In testing, I found 8pm was the cut-off (7:59:59 was normal), which corresponds to the Daylight Savings Time EST UTC offset of -4 hours. After DST, the cut-off should be 7pm. I may have created the calendar before setting the sites default time though. Not sure if it matters that I set it after the fact. I have all of my UTC date setting calibrated now and still see this behavior. I will have to try recreating the calendar with the correct site UTC setting and see if that’s what it is.

Rob Shambaugh

I’m seeing the same issue. I created an event for 10 PM on November 3, but it is showing up on the calendar for November 4. I set Drupal’s default timezone to America/New York when I first created the site. Here’s a screenshot of how it appears on the site: https://drive.google.com/file/d/0B0fLO0s4hgc0RlZsa3RIS3FkWWs/view?usp=sharing

Ivan Maldonado

Hello, Thank´s for the tutorial, it works very good for me but i´m new in drupal and i try to get a mini calendar to use it as a block in any region of mi site, i try to get a block from the created view but i receive this message “Drupal\calendar\Plugin\views\style\CalendarStyle: A calendar date argument is required when using the calendar style, but it is missing or is not using the default date.”. what am i doing wrong?. I have instaled the Calendar and Calendar Datetime, Views, Views UI modules, Date Popup, i use drupal 8.1.3. and what would it be the steps to get the mini calendar? Thanks!!

Ivan Maldonado

Hello, Thank´s for the tutorial, it works very good for me but i´m new in drupal and i try to get a mini calendar to use it as a block in any region of mi site, i try to get a block from the created view but i receive this message “Drupal\calendar\Plugin\views\style\CalendarStyle: A calendar date argument is required when using the calendar style, but it is missing or is not using the default date.”. what am i doing wrong?. I have instaled the Calendar and Calendar Datetime, Views, Views UI modules, Date Popup, i use drupal 8.1.3. and what would it be the steps to get the mini calendar? Thanks!!

Joseph

hi , am (Drupal 8 newbie) following your instructions on how to create a calendar on Drupal 8 but I can’t seem to go past “Add View From Templates” because there’s nothing there. Instead of a list of templates there is a message “There are no available views templates”. What could be the issue?

Marksy

Don’t forget to enable the Calendar module. I did…

dankegel

Hi all! Thanks again to Steve for doing the tutorial.

Support for repeating dates has been a long time coming.

There are signs of motion, though.

For instance, I see https://www.drupal.org/project/date_recur now has a sponsor, it had another alpha release last month, and is up to 131 users (from 37 in March 2017).
And https://www.drupal.org/project/calendar/issues/2699477 had a patch three weeks ago.
It all looks scary and not ready for casual users at the moment, but somehow… it’s alive 🙂

Lisa-B

Hi, is it possible to add more than just text fields into the calendar. Ideally I would like to add a thumbnail image for each event. I’ve tried adding various different sized thumbnails but nothing works. Any suggestions?

Fawad Ali

Hi I follow all the steps and make the calender view but its not giving any report to me. I mean its not showing my data on the calender

Brian L.

The calendar module isn’t available for D8 as of yet.

Joe

Any hints on creating a Block to put in a side-bar?  There is a comment below getting the same error I am getting.

Stevie the Wonder Cat

Thank you soooo much for this.  The documentation for the calendar module is quite horrible. We’re using it on a drupal 9 site.  I was at the point where I wish there was an alternative, so you saved me some blood pressure meds.

mikall

That’s Awesome!  Glad we could help keep the BP in check. lol

50
0
Would love your thoughts, please comment.x
()
x