Date Module - using views to create a listing (without a calendar view)

Events happening in the community are now at Drupal community events on www.drupal.org.
abelb's picture

Hi everyone,

i need a little coding help (i think).

I am using the Date module to create an Event Content type. I used a datetime field to collect, well, the date and time. I have created a view to show the Events listed and grouped by date. (Client does not want a calendar view). So the headings that are grouping the events (set up by using Style: Unformatted and Style Options - grouping Field: field_datetime) are pulling the data out of the field_datetime and thus showing both the Date and Time. I want the heading to show only the Date. How do I remove the time from the heading?

I am not a coder but I am guessing write a function that pulls out only the date from this field and create a new variable. Im guessing I have to call the new variable in a template?

Any help would be greatly appreciated!
andrea

Comments

bgilday's picture
  1. Create two new date formats (Admin >> Site Configuration >> Date and Time >> Formats >> Custom Formats), one called date_only (try this custom format: l F d, Y) and another called time_only (try this custom format: g:i A). You need to create the new name and its format separately, and then 'assign' the format to the name.
  2. Refresh your site cache (Admin >> Site Configuration >> Performance --- clear cached data). This is necessary for these two new date formats to be available when creating your view.
  3. Now go back to the view that you created.
  4. Change your current date field to the time_only format.
  5. Add a second date field (that's right, the exact same field a second time). This time select 'exclude from display' and set the format of this field to date_only
  6. OK, now go back to your grouping field settings and group by the "date_only" field, not the time_only field.
  7. Click save

OK, this should now give you the grouping that you want, grouping events by day, displaying the date_only field as the grouping title and the time_only field next to each event within that day.

Bonus points - if you create this view by cloning the "date_browser" view, you will be able to add date browser navigation at the top of your view to scroll back and forth between months.

I wrote this by memory, so hopefully I didn't miss any steps in the process. If you run into problems, let me know.

Brian Gilday
Municode
www.municode.com

Wow.... thanks!

kcolwell's picture

This single post just saved me a ton of time!

Many, many thanks!

THANK YOU! THANK YOU! THANK

scotthoff's picture

THANK YOU! THANK YOU! THANK YOU! THANK YOU! THANK YOU! THANK YOU! THANK YOU! THANK YOU!

You saved me from a nervous break down!

This is great! thanks

kbond's picture

This is great! thanks

This is great! thanks

kbond's picture

This is great! thanks

I tried cloning the date browser, but it doesn't work

RKopacz's picture

This is right what I was after. I am looking to create a display with a date browser (default by week; my client has 250 - 300 calendar events per week to display), but when I clone the date browser, it does not let me add fields. It is set up as an attachment. I assume that you create the view and then attach the date browser, correct?

In which case, can anyone point me to a good tutorial on attachments? :-)?

Portland (Oregon)

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: