Customizing Fullcalendar display

This topic contains 9 replies, has 2 voices, and was last updated by  Stephen Harris 10 years, 11 months ago.

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #10295

    I’ve been playing with the single event and event meta templates to customize what metadata displays based on a custom field for my events pages. I’d like to do the same thing on the the Fullcalendar view, but there doesn’t seem to be a template for it. Basically, I’m anonymizing Venue and Event Title information for private catered events, but I still want the events to be visible so a) people realize we’re unavailable for catering at those particular times and b) I have opportunities to show the link to our catering request form. I realize that I might be able to use event categories and CSS to replace the titles with the string “Private Event”, but I’d prefer to do this anonymizing via PHP on the back end so that the real information doesn’t come through in the html/javascript source.

    Is there an API to filter some of what gets to the fullcalendar before it gets displayed in a way that’s more powerful than the shortcode options? I’m not a professional developer, but I have access to one. But from looking through the codex, I couldn’t see an obvious analog to using the templates for all the other front-end views.

    Thanks!

    Yoni
    #10300

    Hi Yonatan,

    There is a filter that allows you to alter any event before its added to the calendar. But be aware that the calendar is cached, so any changes via this filter won’t take immediate effect (unless you ‘update’ an event).

    Documentation for this filter can be found here: http://codex.wp-event-organiser.com/hook-eventorganiser_fullcalendar_event.html

    Stephen Harris
    #10302

    Ah, got it. Not sure how I missed that in the codex, though I guess it’s possible I just didn’t quite understand how it works.

    Just to double-check: If I make sure there’s a hook for this filter in place before I actually start using the plugin for “real” events (I’m still just doing a bunch of testing with dummy events for now), then I won’t have to worry about caching, right? Because the filter will change the event’s copy in the fullcalendar the very first time it gets added?

    Yoni
    #10303

    That’s correct. Nor is it cached indefinitely, so after 24 hours it would correct itself.

    Stephen Harris
    #10348

    Thanks again for the help. Now that I’ve dug into the hooks, I realize that it’s better for me to do most of this stuff via filters instead of adding lots of complex logic to the templates. So now I’m wondering if there are ways to hook the venue map. I don’t see anything listed in the codex, so I guess this is probably more of a feature request. Basically I realize I can conditionally display the map based on the event’s Private status by adding an if statement to the templates, but I’d rather hook the map display event so I don’t have to dig around through every template to make sure I didn’t miss any.

    Cheers,
    Yoni

    Yoni
    #10349

    Oh wait, something else just occurred to me. I was trying a neat trick wherein private events aren’t actually anonymized for logged-in users with the ‘edit_events’ capability. Seems to work fine for the rest of the views, but am I correct in assuming it won’t work for fullcalendar? That is, if fullcalendar’s data is cached on the server side and only updated when Events are changed, I can’t reliably expect the filter to get applied in between views by different users (or no user), right?

    Yoni
    #10359

    There’s a bug relating to the cache that it’s not user(-permission)-dependent. In particular private events (visibility set to ‘private’) currently appear on the calendar regardless of whether the user is allowed to view the event’s page (see Settings > Event Organiser > Permissions). But I don’t think altering who gets to see ‘private events’ is something that would help you, as it would remove it from the calendar altogether.

    So in short, you’re correct in thinking that you can’t reliably expect the filter to get applied in between users. But in light of this, I’ll be extending the above patch so that whether the user is logged-in or out is taken into consideration.

    In response to your earlier post regarding the map, eo_get_venue_map() is the last common point for all venue maps being displayed (on the front-end). But quite what the best approach is will depend on what criteria you assess whether a venue should be hidden. (I.e. if a venue has multiple events with some private, and others not – should the venue be shown?).

    The only places the map is used (by default) is the venue map and event map shortcodes, and the template file taxonomy-event-venue.php (where the function is used).

    Stephen Harris
    #10372

    I ended up using my own custom field for Private instead of using WordPress’s built-in visibility. This way I don’t have to alter the query to make sure events that are my version of “Private” show up in listings. Then I’m filtering the_title, wp_title, the_content, and the fullcalendar stuff to hide identifying information from Private events. For everything but the fullcalendar I’m also checking the user’s capabilities. This way a sufficiently privileged user can see the admin details of private/public events on the single event page or archive pages. It’d be great if I could reliably filter the fullcalendar stuff by user but it’s not crucial. OTOH if the cache ever does flush based on user changes, that’d be great too because then I could show my employees draft events so they could use the front end calendar to see confirmed and potential work shifts.

    Yoni
    #10373

    Re: the map stuff, I haven’t gotten a chance to look closer, but the docs make it seem that I can use any arguments accepted by get_posts in the shortcode, so presumably I can use something like [event_map meta_key=”event_public_private” meta_value=”Public”], and filter by my own custom field right?

    And then I think if a venue has a mix of private and public events, I’d still want it to show up on the map. I’d just have to figure out if I could correctly hook eventorganiser_venue_tooltip (or is it eventorganiser_event_map_tooltip), so that only the Public ones show up on the map tooltip for non-credentialed users. It seems doable but it’s not totally obvious yet.

    Yoni
    #10374

    I’ve not tested meta queries, but it should work. The attributes are just passed to eo_get_events() (after some of the attribute keys are ‘corrected’ e.g event_category to event-category), so while arguments with array values (such as tax_query) wouldn’t work, meta_key and meta_value should.

    It’s eventorganiser_event_map_tooltip you’ll want. That passes an array of events that are shown in the tooltip.

    Stephen Harris
Viewing 10 posts - 1 through 10 (of 10 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.