Home › Forums › Calendar Products › Filter Bar › Filter bar preselection
- This topic has 8 replies, 2 voices, and was last updated 10 years, 6 months ago by
Nico.
-
AuthorPosts
-
October 7, 2015 at 1:32 am #1012161
Jacob
ParticipantHelloo modern tribe team,
I want the filter bar to
1. preselect 1 certain venue
2. and display this venue on top of the listCan you help me now to configure this?
Best,
JacobOctober 7, 2015 at 7:56 am #1012322Nico
MemberHi Jacob,
Thanks for reaching out to us! I’ll try to help you out on this…
Unfortunately there’s no configuration available to do this. Per default Venues are ordered by title in the filter, but you can add a filter to change the order of the filter values:
add_filter( 'tribe_events_filter_values', 'modify_filter_values', 20, 2);
function modify_filter_values ( $values, $slug ) {
if($slug == 'venues') {
// as an example revert the order
$values = array_reverse ( $values );
}
return $values;
}
Regarding the selection of the filter you can link users to the filtered URL. For example: http://site.com/events/?tribe_venues%5B%5D=28 (where 28 is desired venue ID). If you want to maintain the URL without changes then maybe a JS snippet to ‘check’ the filter after the page loads is the way to go.
Please let me know if I understood this correctly in first place,
Best,
NicoOctober 8, 2015 at 11:43 am #1012790Jacob
ParticipantHello Nico,
Thank you for taking time for me.
I am wondering if i can order the venue list so that one specific venue is listed on top. Is there a way for that?
The preselected page is a good solution for me. Please help me how to find out the venue id. I cannot see it when I check the venue list in the WP backend.
Best,
JacobOctober 8, 2015 at 1:11 pm #1012828Nico
MemberHey Jacob,
Thanks for following up!
I am wondering if i can order the venue list so that one specific venue is listed on top. Is there a way for that?
I guess it’s possible via some php array functions!
The preselected page is a good solution for me. Please help me how to find out the venue id. I cannot see it when I check the venue list in the WP backend.
To get the ID of the desired venue, edit it in the backend and the ID will show in the URL just like this: https://cloudup.com/cHlH_HtSXg7
Please let me know if there’s anything else I can do for you,
Best,
NicoOctober 8, 2015 at 2:21 pm #1012858Jacob
ParticipantHello Nico,
Thank you. I checked out the list, but I can’t find the proper array that could do the job. Do you have a hint for me?
Thanks for the advise for finding the ID. That idea really serves my wish for the preselected view!
Best,
JacobOctober 8, 2015 at 10:44 pm #1012990Jacob
ParticipantHello Nico,
I have found the array. In your function proposal I need to replace the array by array_unshift which moves an item to the top of the list. Can you just tell me what to type after the array_unshift? For that I need to find the array name and the value of the array key (my specific venue) in the events calendar code.
Best wishes,
JacobOctober 9, 2015 at 8:52 am #1013182Nico
MemberHey Jacob,
Thanks for trying that out before hitting the forums again, this one requires a bit of PHP knowledge I guess!
Here’s the snippet, just replace the value for $venue_id with the correct value:
/* Modify Venues list for FilterBar */
add_filter( 'tribe_events_filter_values', 'modify_filter_venues', 20, 2);
function modify_filter_venues ( $filter_values, $slug ) {if($slug == 'venues') {
$venue_id = 99;if ( $key = array_search($venue_id, array_column($filter_values, 'value')) ) {
$selected_venue = array_splice($filter_values, $key, 1);
array_unshift($filter_values, $selected_venue[0]);
}
}return $filter_values;
}
Please let me know if you can make this work on your site,
Best,
NicoOctober 9, 2015 at 10:43 am #1013231Jacob
ParticipantGreat, thank you Nico, it works perfectly!!!
Yipiiieehhh!!!!
October 9, 2015 at 2:45 pm #1013323Nico
MemberHey Jacob!
Stocked to hear this is working for you 🙂
I’ll go ahead and close out this thread, but if you need help with anything else please don’t hesitate to create a new one and we will be happy to assist you.
Have a great weekend,
Nico -
AuthorPosts
- The topic ‘Filter bar preselection’ is closed to new replies.
