Cách tạo một trang Calendars trong Drupal 7

Cách tạo một trang Calendars trong Drupal 7

We're going to show you how to create an event calendar in Drupal.

This tutorial is ideal for people who want to show a monthly, weekly or daily list of upcoming events.

First, we'll show you how to set up a basic Calendar and then we'll modify it to the needs of your content.

Installation

You'll need to enable and install these modules:

When you're enabling these modules, make sure to enable both Date API and Date Views.

Setting up the calendar

Go to Structure > Views > Add view from template.

media_1371647626258.png

You'll now see a variety of default Views that can be created.

  • Click add next to "A calendar view of the 'created' field in the 'node' base table".

media_1371647669125.png

  • Choose a name of your new Calendar view.
  • Click Continue,

media_1371647861090.png

  • Scroll to the bottom of the page for the preview.
  • You'll see that there's a calendar view with content inside.

media_1371647880886.png

  • Click Save in the top-right corner of your View.
  • Visit the site's homepage.
  • There will be a link in the Navigation menu to your Calendar.

media_1371647903708.png

  • You'll see your calendar on your site. The first tab will be a Month view.

media_1371647931988.png

  • Click the tabs across the top to get a Week, Day and Year view:

media_1371647950715.png

At the moment the calendar looks good, but we have some problems:

  • The calendar is showing all of the content on our site, not just events.
  • The calendar is sorting the content by the date it was published, not the date the event is happening.

Let's modify the calendar to fix those problems.

Modifying the Calendar

The first thing we need to do is make sure we have a place to list our Events. If you haven't done so yet. we'll create a content type called Events.

  • Go to Structure > Content types > Add content type
  • Enter Events as the Name
  • Click Save and add fields
  • Create a field called Date and choose Date as the type of data to store.
  • Click Save, then Save field settings, then Save settings.

media_1371648217889.png

Your Events content type should like at least a little like this:

media_1371648244320.png

  • Go to Structure > Views
  • Click Edit in the row for our Calendar view.
media_1371651090082.png

We need to change two things on the left-hand side of our view. We need to change:

  1. Fields
  2. Filter Criteria
  3. Sort Criteria

media_1371648336204.png

First, let's change the Fields. We're going to remove the date that the content was posted to our site.

  • Click Content: Post Date
  • Click Remove

Now we're going add the date of the events:

  • Click Add next to Fields.
  • Choose Content: Date
  • Click Apply (all displays) twice

When you're finished, your Fields area will look like this.

media_1371648484344.png

Second, we're going to use Filter Criteria to make sure that only our Events show on the calendar.

  • Click Add next to Filter Criteria.
  • Choose Content: Type
  • Click Apply (all displays)
  • Choose "Is one of" and then "Events".
  • Click Apply (all displays)

media_1371648559433.png

Your Filter Criteria will look like this:

media_1371648611595.png

Now we need to look to the right-hand side of our Views editing screen.

  • Under Contextual Filters, click Date: Date (node) (Content: Post date)

media_1371649163260.png

  • At the top of the screen, make sure you are configuring this option for All displays:

media_1371649534444.png

  • Uncheck Content: Post date
  • Check Content: Date (field_date)
  • Click Apply (all displays)

media_1371649188435.png

  • Check the preview of your view and your events should be showing on the date they will happen.
  • Click Save
  • Visit your finished calendar on the front of your site.

media_1371651971852.png

Bạn thấy bài viết này như thế nào?: 
No votes yet
Ảnh của Tommy Tran

Tommy owner Express Magazine

Drupal Developer having 9+ year experience, implementation and having strong knowledge of technical specifications, workflow development. Ability to perform effectively and efficiently in team and individually. Always enthusiastic and interseted to study new technologies

  • Skype ID: tthanhthuy

Tìm kiếm bất động sản

 

Advertisement

 

jobsora

Dich vu khu trung tphcm

Dich vu diet chuot tphcm

Dich vu diet con trung

Quảng Cáo Bài Viết

 
Teens Exploring Technology tạo sự khác biệt gì tại South Los Angeles?

Teens Exploring Technology tạo sự khác biệt gì tại South Los Angeles?

Oscar was looking into Drupal as a potential technology to include in the summer coding academy his organization holds every year.

Hướng dẫn custom entity reference: Drupal & Entity reference

Hướng dẫn custom entity reference: Drupal & Entity reference

There are some good examples out there on how to create a custom Entity reference Behaviour plugin, but not so much for Selection handlers.

Máy tính bảng giá rẻ Kindle Fire cũng bị phàn nàn

Máy tính bảng giá rẻ Kindle Fire cũng bị phàn nàn

Mặc dù Kindle Fire đang bán khá chạy và có thể sẽ có một bản cập nhật phần cứng vào đầu năm 2012

Công ty diệt chuột T&C

 

Diet con trung