Forum

Thread tagged as: Addons, Events

Filter events by category

Hi. New to Perch. Brilliant so far. I'm stuck with the event app though. It works fine with the examples but I would like to display only events from a certain category.

How do I go about this? Any help appreciated.

Steven Bradley

Steven Bradley 0 points

  • 7 years ago
Rachel Andrew

Rachel Andrew 394 points
Perch Support

https://docs.grabaperch.com/addons/events/page-functions/standard/

You can pass in a single category or an array.

Thanks Rachel, that's great - have used that now. I'm still getting to grips with this and don't fully understand how slugs can help with events. I don't suppose you can point me in the direction of a working event using a slug function - if that makes sense.

Drew McLellan

Drew McLellan 2638 points
Perch Support

It doesn't much - can you give an example?

Sorry, will try to explain. I can see that Slugs will be useful for returning Urls, but there are two listed in the template for events - category_slugs and eventSlug. I assumed prior to my question above that the slugs would be used to filter categories, but if the events_custom array can be used to filter categories - why is it needed?

For example I'm trying to find 3 events related to the beach. Rachel's suggestion helped me do the following, but where would you use a Slug relating to events in something below. Just trying to get my head around when it would be best to use slugs that's all.

      perch_events_custom(array(
'filter'   => 'eventDateTime',
'match'    => 'eq',
 'count'=>3,
'category' => array('beach'),
'template' => 'events/listing/event-day.html'

));

Thanks Steve

Drew McLellan

Drew McLellan 2638 points
Perch Support

I'm not sure what problem you're trying to solve. All a slug is is a URL-safe text identifier for the item.