We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum

Forum

Thread tagged as: Question, Events

How do I not show a specified events category in a listing options array?

A client site has two calendars, one for events related to their club, and another for events being booked at their club. On the homepage is to be a listing of the former.

How do I specify in the options array to show events in all categories except bookings, for example?

Gary Iverson

Gary Iverson 0 points

  • 5 years ago

Hello I have done something similar to show featured events on the home page of NW Bloodbikes I used this code:

<?php 
            $opts = array(
                'filter'=>'eventDateTime',
                'match'=>'gte',
                'value'=>date('Y-m-d'),
                'category'=>array('featured'),
                'count'=>1,
                'sort'=>'eventDateTime',
                'sort-order'=>'desc',
                'template'=>'events/listing/custom-listing-featured.html'
            );
            perch_events_custom($opts);

        ?>

You would just have to add the other categories except bookings and increase the count I think.

That's essentially what I have now, although its not optimal. What if the client adds new event categories? The array would need to be updated each time.

Drew McLellan

Drew McLellan 2638 points
Perch Support

You can use perch_events_categories() with the skip-template option to get an array of categories which you can then iterate through.

Drew McLellan said:

You can use perch_events_categories() with the skip-template option to get an array of categories which you can then iterate through.

What does this function perch_events_categories() do? How can I output a list of categories like perch_gallery_albums()?

Andrew Liu said:

Drew McLellan said:

You can use perch_events_categories() with the skip-template option to get an array of categories which you can then iterate through.

What does this function perch_events_categories() do? How can I output a list of categories like perch_gallery_albums()?

Ok, I found it on the events runtime file, thanks