user tip Enhancing the Output of Start/End Date in Events

Clay Gordon
Clay Gordon
@claygordon
8 years ago
733 posts
Many of the events on my site take place over the course of several days and the default setup does not support the idea of displaying both a start and end date.

I also wanted the ability to display the starting time, but only if the event was not marked as an all-day event.

My event creation form enables me to list both a start and an end date ( item.event_end_date ) as well as to indicate whether or not the event lasts all day or starts at a particular time. YMMV.

The corresponding templates need to have the code necessary to display all of this information.

Following is the code that generates the dates display in the attached. It goes in two templates:

jrEvent item_list.tpl
jrEvent item_detail.tpl

I have not included line numbers because I have modified my templates in other ways and I can't guarantee they'd be the same in yours. However it should just take a few moments to paste it in. I don't remember if the default event form as the end date field, so you may need to use the Form Designer to add it in. I used "event_end_date" for the field name - if you use something else then the code below will need to be modified to accommodate this.

Please note that the event listing entry form itself has no ability to check if the end date for an event occurs after the start date (the default is to set it for the same date). This has to be verified manually.

Pseudocode:
1) Check to see if the end date is greater than the start date.
2) If it is, display both dates.
3) If the end date is not greater than the start date, check to see if "all day" is selected.
4) If it is, then display just the start date.
5) Otherwise display the start date and time.

{if $item.event_end_date > $item.event_date}
     {$item.event_date|jrCore_date_format:"%A %B %e"}  –  {$item.event_end_date|jrCore_date_format:"%A %B %e %Y"}
{elseif $item.event_allday == "on"}
     {$item.event_date|jrCore_date_format:"%A %B %e %Y"}
{else}
     {$item.event_date|jrCore_date_format:"%A %B %e %Y, %l:%M %p"}
{/if}

Thanks to Paul and Michael for helping me work this out. The support from the Jamroom team is nothing short of top-notch.
updated by @claygordon: 07/15/16 06:52:09PM

Tags