Support

Home Forums Event Espresso Premium Filtering by venue, custom search

Filtering by venue, custom search

Posted: May 11, 2015 at 9:01 am

Viewing 5 reply threads


Damian Way

May 11, 2015 at 9:01 am

Hi there,

I am trying to set up a custom search which lists events but can’t get it to filter by venue.

Should I be able to do this?

`$search_args = array(
‘show_expired’ => FALSE,
‘category_slug’ => $category_slug,
‘order_by’ => ‘start_date’,
‘sort’ => ‘ASC’,
‘venue’ => $venue_id,
);
$events= new EE_Event_List_Query( $search_args );`

Thanks in advance.


Dean

May 12, 2015 at 1:51 am

Hi,

Looking at the code here /wp-content/plugins/event-espresso-core-reg/shortcodes/espresso_events/EES_Espresso_Events.shortcode.php and on the http://code.eventespresso.com/class-EE_Event_List_Query.html it does not look like you can just drop in the venue aspect.

I think it’s probably best to use the loop and then on each event check for venues, so for example add this into the loop:

EE_Registry::instance()->load_helper( 'Venue_View' );
$venues = EEH_Venue_View::get_venue();
echo "<pre>" . print_r( $y, 1 ) . "</pre>";

Obviously, that will dump out any related venues for the event, but you can get the appropriate data from it. Then you can use the get method to pull out the data.

For example you could use:

echo $venues->get('VNU_name');

Which will echo out the venue name.

Does that help?


Damian Way

May 12, 2015 at 2:09 pm

Hi Dean,

Thanks for your quick reply, I am looking to only show events for a particular venue though (as well as other search criteria) which doing it this way will be very slow no?


Dean

May 13, 2015 at 2:00 am

Hi,

It will be slower, but whether it is noticeably slower is hard to say without benchmark testing.

However, there really isn’t another way: the event post type doesn’t hold the venue data, nor does the post meta.

Right now the only way I can see it working would be to get the events and filter them by venue as discussed above.

There is an SQL join with the venues in /wp-content/plugins/event-espresso-core-reg/core/helpers/EEH_Event_Query.helper.php but this seems to only be applicable if the event query uses the order_by parameter.


Damian Way

May 18, 2015 at 3:15 am

Hi Dean,

So that would only work if the venues are ordered by venue?

I am guessing I could do it with a custom SQL query, I don’t suppose you have any SQL examples for joining the event and venue tables?

Thanks

Damian


Dean

May 18, 2015 at 3:31 am

Hi,

So that would only work if the venues are ordered by venue?

Pretty much yeah, it just allows the events to be ordered by venue.

Well, my SQL-fu is somewhat limited but I came across this in /wp-content/plugins/event-espresso-core-reg/core/db_models/EEM_Base.model.php (comments)

SELECT * FROM wp_posts AS Event_CPT
LEFT JOIN wp_esp_event_meta AS Event_Meta ON Event_CPT.ID = Event_Meta.EVT_ID
LEFT JOIN wp_esp_event_venue AS Event_Venue ON Event_Venue.EVT_ID=Event_CPT.ID
LEFT JOIN wp_posts AS Venue_CPT ON Venue_CPT.ID=Event_Venue.VNU_ID
LEFT JOIN wp_esp_venue_meta AS Venue_Meta ON Venue_CPT.ID = Venue_Meta.VNU_ID
WHERE Venue_CPT.ID = 12

I haven’t tested it but it looks like a good starting point.

I do know that you will need to use the *_esp_event_venue (* = table prefix) table to join the event post and venue posts together.

Viewing 5 reply threads

The support post ‘Filtering by venue, custom search’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso