In this video, we will create a content type for upcoming events. This content type will have fields for event title, type of activity, start and end date/time and event details. And since it will contain date fields, let's start out by installing the Date module.
Install module
Enable modules
- Date (This will make the date and time fields available to any content type)
- Date All Day (This will add the "All day" function to date fields)
- Date API
- Date Popup (This will enable a popup jQuery calendar date picker and time picker in date and time fields)
- Date Repeat API
- Date Repeat Field (This will add the "Repeat" function to date fields)
- (Save configuration)
Once the Date module has been enabled, you'll be reminded to set up the regional settings as well as the date and time settings. To set up the regional settings, click the "site timezone and first date of week settings" link or go to "Configuration => Regional and language => Regional Settings" and to set up the date and time settings, go to "Configuration => Regional and language => Date and time". I'm going to leave the timezone settings as they are, but I'll change the date formats to the ones most commonly used where I live.
When we create out events, we'll categorized them by the type of activity. So before we create the content type, let's create a vocabulary and add a few terms.
Create Taxonomy Terms
- Go to "Structure => Taxonomy => Add vocabulary" (admin/structure/taxnonomy)
- Name: Activity Type
- (Save)
Add terms
- Click "add terms" for Activity Type
- Name: Conference
- (Save)
- Name: Exhibition
- (Save)
- Name: Performance
- (Save)
- Name: Special Event
- (Save)
Now, we can go ahead and create the "Event" content type.
- Go to "Structure => Content types => Add content type" (admin/structure/types/add)
- Name: Event
- Description: An upcoming event
- Submission form settings
- Title field label: Event Title
- Publishing options
- Default options
- [ ] Promoted to front page
- Display settings
- [ ] Display author and date information
- Comment settings
- Default comment setting for new content: Closed
- (Save and add fields)
By default, our “Event” content type only has fields for Event Title and Body. Let's add new fields for activity type, start and end dates and event details.
Add new field
- Label: Activity Type
- Field Type: Term Reference
- (Save)
- Field settings
- Vocabulary: Activity Type
- (Save field settings)
- (Save Settings)
Add new field
- Label: Event Date
- Field Type: Date
- Widget: Pop-up calendar
- (Save)
- Field settings
- [x] Collect an end date
- [x] Required
- Repeating date: Yes
- (Save field settings)
- Event settings
- [x] Required field
- Expand the "More Settings and Values" section
- [x] Display all day checkbox
- Default date: No default value
- (Save settings)
Add new field
- Label: Event Details
- Field type: Long text and summary
- (Save)
- (Save field settings)
- (Save settings)
We'll no longer need the Body field because we created an "Event Details" field, so we can just delete it.
- Click "delete" next to "Body"
- (Delete)
We now have the "Event" content type with the necessary fields. Now, let's create four events to display on our calendar.
Create Content
- Go to "Content => Add content => Event" (node/add/event)
Create Event #1
- Event Title: Event #1
- Activity: Conference
- Event Date
- (From) Date: 04/14/2014
- (From) Time: 08:00am
- (To) Time: 04/15/2014
- (To) Date: 06:00pm
- Event Details: (Lorem Ipsum)
- (Save)
Create Event #2
- Event Title: Event #2
- Activity: Exhibition
- Event Date
- (From) Date: 04/16/2014
- (From) Time: 08:00am
- (To) Time: 04/16/2014
- To) Date: 06:00pm
- [x] Repeat
- Repeats: Choose "Weekly"
- Repeats: Every "2" weeks
- Stop repeating
- After: 10 occurrences (You could also stop repeating on a specific date)
- I'll leave the rest of the settings alone, but you'll also have options to:
- Repeat only on specific days of the week
- Exclude and/or include specific dates
- Event Details: (Lorem Ipsum)
- (Save)
Create Event #3
- Event Title: Event #3
- Activity: Performance
- Event Date
- [x] All Day
- (From) Date: 4/22/2014
- (To) Date: 4/22/2014
- Event Details: (Lorem Ipsum)
- (Save)
Create Event #4
- Event Title: Event #4
- Activity: Special Event
- Event Date
- (From) Date: 04/28/2014
- (From) Time: 09:00am
- (To) Time: 04/30/2014
- To) Date: 05:30pm
- Event Details: (Lorem Ipsum)
- (Save)
Alright, now we have four events created. So in the next video, we will install and enable the calendar module and all its required dependencies, then create a calendar view.