Forum

Thread tagged as: Question, Addons, Events

Output events with the category that matches the url slug of another page

Hi,

I have a detail page with the url /open-programmes/core-level-coaching

On that page I want to output events with the category_name that matches the url or page that the event name would relate to ie. page /core-level-coaching outputs events in category='core-level-coaching'. The pages are dynamic and so I can't specify the category in the perch_events_custom tag. If there;s a way of matching the page url to an event category_slug then I will be a happy man :-)

On the /open-programme.php (detail page) I have tried this based on another discussion I read but nothing outputs:

URL = /open-programmes/core-level-coaching

<?php perch_events_custom(array(

            'filter'     => 'category_slugs',
            'match'      => 'contains',
            'value'      => perch_get('s'),
            'category'   => perch_get('s'),
            'template'   =>'events/listing/event-list-sidebar.html'

        )); 
?>

Is it possible?

I'm incapable of writing any php that doesn't come out of the box, so I may even be trying to do something here that's not even possible (or possible in a simple way)!

Cheers, Greg

Studio Daughter

Studio Daughter 0 points

  • 2 years ago

Erm, I think I've only gone and done it!. Good old fashioned 'trial and error having no idea what you're' doing seems to have worked!

I just removed the 'match' and 'value' options and hey presto, there it is on the page.

<?php perch_events_custom(array(

            'filter'     => 'category_slugs',
            'category'   => perch_get('s'),
            'template'   =>'events/listing/event-list-sidebar.html'

        )); ?>

I won't celebrate too soon though.

Drew McLellan

Drew McLellan 2406 points
Perch Support

The line 'filter' => 'category_slugs', does nothing in this context, so you can remove it.

Cool, thanks Drew.