Forum

Thread tagged as: Question

Custom Events Listing

Hi Perch,

I'm trying to create a list of events to look something like this. I don't want to re-list the Day/Date when an event is on the same day.

Monday, 14th December 2015
1:00 pm Mulled wine and mince pies
7:15 pm Christmas Concert

Thursday, 31st December 2015
9:00 am Frantic clean of house ready for party
8:16 pm New Year's Eve Party

Friday, 11th March 2016
10:16 am Spring is here.

So far, I just have the following simple custom template. Is there a way within the perch template for me to check if the previous listed date equals the current date (so I can then only display the <h3></h3> portion when the dates differ):

<perch:before><ul class="calendar"></perch:before>
  <li>
    <h3 class="date small"><perch:events id="eventDateTime" format="l, jS F Y" /></h3>
    <div class="vevent">
        <perch:events id="eventDateTime" format="g:i a" /> <a href="<perch:events id="eventURL" />"><perch:events id="eventTitle" /></a>
    </div>
  </li>
<perch:after></ul></perch:after>
<perch:noresults>
    There are no events currently scheduled.
</perch:noresults>
Jane Turnbull

Jane Turnbull 0 points

  • 5 years ago

ps. sorry example is a bit unclear. There should be line breaks under the day/date and each individual event timed event - which didn't come out.

Drew McLellan

Drew McLellan 2638 points
Perch Support

You need to use the different attribute with perch:if.

<perch:if different="eventDateTime" format="l, jS F Y">
    <h3 class="date small"><perch:events id="eventDateTime" format="l, jS F Y" /></h3>
</perch:if>

aha! Perfect! Thanks so much!

This is a great feature!