… in my Testcalendar ist the only event with a location:
Monday 21. December = TEST / Gubener Straße
Plugin Author
room34
(@room34)
Unfortunately, there’s not really a way to filter the list in this way right now.
If it’s possible for you to set up a second calendar that just has those events, that would be an option. Another possibility, though it wouldn’t actually keep the other events from appearing in the HTML (but they would not display on the page), would be to fake it with some jQuery. Something like this might work:
jQuery('.ics-calendar-list-wrapper .location').each(function() {
if (jQuery(this).text().indexOf('Gubener Straße') == -1) {
jQuery(this).closest('.event').remove().prev('.time').remove();
}
});
jQuery('.ics-calendar-list-wrapper h4').each(function() {
if (jQuery(this).next('dl').children('dd').length == 0) {
jQuery(this).remove();
}
});
That would take all events that do not contain “Gubener Straße” in the location out of the page, and then remove any date headers if their event list is now empty.
(Note: I haven’t actually tested this code. I’m not 100% sure the .prev('.time').remove()
will work after the .event
has already been removed, so you might need to split that into two lines and remove the .time
first.)
Thank you for your feedback!
The jOuery script would be enough for me. Where do I have to use or copy it. what do I have to write in to the shortcode?
Plugin Author
room34
(@room34)
I just remembered there’s a better way to do this.
There’s a filter called r34ics_display_calendar_filter_ics_data
. In your theme’s functions.php file you could use:
add_filter('r34ics_display_calendar_filter_ics_data', function($ics_data) {
foreach ((array)$ics_data['events'] as $key => $event) {
if (strpos($event['location'], 'Gubener Straße') === false) {
unset($ics_data['events'][$key]);
}
}
return $ics_data;
});
This will actually remove those events from the data before rendering, so it’s not in the HTML at all, and you wouldn’t need to do anything funny with jQuery.
i have copy this to my theme function. but by now, it shows me no events – but i have now no event with “Gubener Straße” in my calendar…. ?
-
This reply was modified 1 year, 8 months ago by
BrandBull.
My Shortcode is like this:
[ics_calendar url=”webcal://p39-caldav.icloud.com/published/2/Mjc0MDg5MjYwMjc0MDg5MpPy4gAYuun5hgl6QNH7-RjbO1JKJ3XtQPxRRPlhBnv2yB2vCg5HeT5nEAhUNBMPQSC1-CzBtmcjrhpwoXxcKMI” title=”DISPLAY_TITLE” view=”list” count=”15″ color=”#ffffff #008000 #ffa500″ hidetimes=”true” skip=”NUMBER” location=”true”]
… did you have a solution for me, why this is not working or no event will display on my calendar ?
Plugin Author
room34
(@room34)
Sorry, it’s been a while since I’ve worked with some of these filters. The one I gave you was incorrect. Please delete that first code block and use this instead:
add_filter('r34ics_display_calendar_exclude_event', function($exclude, $event, $args) {
if (empty($event->location) || strpos($event->location, 'Gubener Straße') === false) {
$exclude = true;
}
return $exclude;
}, 10, 3);
… unfortunately this block doesn’t work either … 🙁 … do you have another solution? Thanks, Olli
… sorry, now it works… can i spend you some beer?
Plugin Author
room34
(@room34)
Glad it works now! I didn’t mention that you might need to add reload=”true” to bypass the built-in caching to get it working immediately.
yeah, works perfect…. THANK YOU!!!!!!!!!