Forum

Thread tagged as: Problem

Problem with Events Listing

Hi,

The perch_events_listing almost does exactly what I want. Events on a particular day are all neatly listed under the relevant day. Events on different days are listed under their respective days. I want to show the first 8 events rather than the default 3. I have the standard perch events templates set up. I thought that all I would need to do is change my call from:

perch_events_listing();

to

<?php
perch_events_custom(array(
'filter'   => 'eventDateTime',
 'match'    => 'gte',
'value'    =>  date('Y-m-d'),
 'count'       =>  8,
 'sort'=>'eventDateTime',
  'sort-order'=>'desc',
));
?>

This doesn't work though. It does print the first eight events, but all under the first day it comes across, even if an event is on a different day. I also tried adding in the standard template of event-day.html but that just yields the same results. ie. all future events are listed under the very first day, even if they're on different days.

With the perch_events_listing(); call, it all works fine and each set of events are listed under the correct relevant days.

I'm sure I'm just doing something really silly or missing something obvious, but can't figure out what is wrong - I'm using the standard events templates.

Jane Turnbull

Jane Turnbull 0 points

  • 5 years ago

ignore the default 3 statement. I just want to list the first 8 events regardless of when they are.

Drew McLellan

Drew McLellan 2638 points
Perch Support

This doesn't work though. It does print the first eight events, but all under the first day it comes across, even if an event is on a different day.

This sounds like a templating issue. What does your template look like?

HI Drew,

<perch:before>
    <li>
        <h3><span class="day"><perch:events id="eventDateTime" format="l, jS F Y" /></span></h3>
        <ul>
</perch:before>

            <li class="vevent small">
                <span class="time dtstart"><span class="value-title" title="<perch:events id="eventDateTime" format="c" />"><perch:events id="eventDateTime" format="%l:%M %p" /></span> - </span>
                <span class="event summary <perch:events id="category_slugs" />"><a href="<perch:events id="eventURL" />"><perch:events id="eventTitle" /></a></span>
                <div class="description">
                    <perch:events id="eventDescHTML" encode="false" />
                </div>
            </li>

<perch:after>            
        </ul>
    </li>
</perch:after>

It's just picking up the very first event day it finds, then looping around every single event up to 8 in the future, regardless of whether the future event belonged to that date or not. I wanted it to loop similar to the perch_events_listing():

ie. For each day that has an event: * List the day * - show event one on that day - show event two on that day - etc then loop back to the next day that has an event and repeat.

What's happening is: * I'm listing the first day I find that has an event on it. - list event one on that day - list event two on that day - list ever three (even though it's not on this day) - list event four (even though it's not on this day) - etc up to count.

So I never get any other day headings. It's missing the code above which initiates the first loop (over each day) and I'm not sure how to find it.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Your <h3> with the date is in the perch:before section, so it will only ever display for the first item.

I thought this template would handle the "multiple events on one day scenario", but I'm stuck on how to get perch to move on to loop to the next day that has events. What am I missing (apart from some grey matter)?

If I change the template to this, then I get the <h3> day listed for every event within that day. I only want the <h3> once for a day and all the events on that day underneath. Then repeat for next day that has events.

<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>

So basically for the next event, I don't want to repeat the <h3> day title if the next event is on the same day.

Drew McLellan

Drew McLellan 2638 points
Perch Support

<perch:if different> That's just perfect Drew. I knew there would be some way but couldn't find it. Thanks so much for your patience and help.