Cấu hình Views làm việc Correctly Display Repeating Date Fields

Cấu hình Views làm việc Correctly Display Repeating Date Fields

Configuring Views and Date is a simple enough task for any reasonably experienced site builder, but I’ve found that configuring Views to correctly handle and display repeating events is another matter. To get us started, I’ve installed the following modules: 

- Views Views UI

- Date  Date Repeat Field, Date Views

I created a content type called “Event”. The next step is to add and configure a Date field. While configuring, make sure you set “Repeating Date” to “Yes”. 

The rest of the settings are more or less up to you depending on your needs, but if you’re not sure, the defaults should be fine. You’ll notice that the “Number of Values” setting is grayed out. This is because repeating Date fields required Unlimited values.

Now that your Date field has been configured, create a piece of test content. This will come in handy while you’re building your View. Any sort of repeating event will do. For this example, I’ll be using an event that repeats on the second Thursday of each month for the next three years.

Now that we have some content to work with, we can create our view. This view will have one Page type display, showing content of the Event type as an unformatted list of fields. Generally, the first thing you will want to do is add a filter to the view to prevent it from showing past events. If you do want past events to be shown, skip this section, otherwise, add a new filter for the Date field on your Event content type. If you chose to use a Date field with both a Start and End date, you’ll want to select the Start date for the filter.

Generally, I prefer Minute granularity, and you must select “Yes” for “Add multiple value identifier”. Next, set the filter itself to “greater than or equal to” and a relative time of “now”.

Cấu hình Views làm việc Correctly Display Repeating Date Fields

Now your view will only display current and future events. With the addition of this filter, the single event in your preview should have changed to multiple events. The next step: adding and configuring the Date field itself.

The settings for the Date field are fairly simple. In most cases, you’ll want to hide the repeat rule. However, you must uncheck “Display all values in same row” under “Multiple field settings”, or the view will not correctly display the dates.

The resulting view should be a perfectly serviceable list of your upcoming events. However, there is one optional extra step: for a given event, only displaying the next occurrence, not any past occurrences or more than one future occurrence. To do this, you’ll need to enable two settings under the Advanced tab on the right. The first is Aggregate, which is under the “Use aggregation” option. 

The second option we need to enable is Distinct, which is under the “Query settings” option:

This, combined with the filter we made earlier, will cause your view to display only the next upcoming event for a recurring event series. And with that, you’re done: your view now displays recurring date fields correctly.

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

Khanh Hoang - Kenn

Kenn is a user experience designer and front end developer who enjoys creating beautiful and usable web and mobile experiences.

Bình luận (0)

 

Add Comment

Filtered HTML

  • Các địa chỉ web và email sẽ tự động được chuyển sang dạng liên kết.
  • Các thẻ HTML được chấp nhận: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Tự động ngắt dòng và đoạn văn.

Plain text

  • No HTML tags allowed.
  • Các địa chỉ web và email sẽ tự động được chuyển sang dạng liên kết.
  • Tự động ngắt dòng và đoạn văn.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.

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

 
Buổi ra mắt Facebook Home không khác gì lần thuyết trình về Windows Phone 7.5

Buổi ra mắt Facebook Home không khác gì lần thuyết trình về Windows Phone 7.5

Frank Shaw, phó chủ tịch phụ trách truyền thông của tập đoàn Microsoft, cho rằng nội dung buổi ra mắt Facebook Home không khác gì lần thuyết trình về Windows Phone 7.5 cách đây hai năm.

Hướng dẫn alter the Webform submission trước khi lưu database

Hướng dẫn alter the Webform submission trước khi lưu database

In this article we are going to look at a cool Webform api function that allows us to interfere with the submissions being saved to the database.

 Hướng dẫn chung khi mua bộ chuyển đổi, sạc, bộ nguồn

Hướng dẫn chung khi mua bộ chuyển đổi, sạc, bộ nguồn

Adapter (bộ chuyển đổi, sạc, bộ nguồn) là bộ phận cung cấp nguồn điện cho laptop kiêm luôn chức năng sạc pin, đóng vai trò hết sức quan trọng, quyết định tính ổn định của laptop của bạn.

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

 

Diet con trung