Hi Stephen
Once more: your plugin is brilliant – and makes fun to work with.
I could not solve an issue even after investigations for hours. Could you kindly help me with the following:
I am using the eo_fullcalendar with agendaWeek.
How can I adjust the content of the fc-content?
I want to add a «sold-out»-mark when there are no tickets left and second I want to add the author (here: teacher) to the full calendar. (see screenshot)!
Thanks for your help in advance.
Cheers, Benjamin.
Benjamin Ogg
I think the only way to do this is to use the eventorganiser_fullcalendar_event
hook to inject any extra data for each event (see codex: http://codex.wp-event-organiser.com/hook-eventorganiser_fullcalendar_event.html) – note that the calendar is cached. After making any changes, update an event to clear the cache.
Then, you can use the following JS-hook (see https://github.com/carldanley/WP-JS-Hooks for background):
addFilter( 'eventorganiser.fullcalendar_render_event', function( render, event, element, view ){
console.log( event ); //for debugging, the contents of the event object.
console.log( element ); //for DOM element corresponding to this event.
return render;
});
The element
should contain the mark-up for the event cell, so you can modify it as you wish using jQuery.
I’m confident that it will work, but I’ve not tested it. So you may want to try manipulating the element
before you try to pass data to your code via the eventorganiser_fullcalendar_event
filter.
Stephen Harris
Cheers, Stephen! That helped.
I am adding the following code to the eventorganiser_fullcalendar_event
function:
$remaining = eo_get_remaining_tickets_count( $event_id, $occurrence_id );
if ( $remaining == 0 ) :
$event['title'] .= 'soldout';
endif;
Is it possible to wrap the «soldout» with a span or div for styling reason?
Benjamin Ogg
Hi Benjamin,
No you won’t be able to as it escapes any HTML.
What you can do is set:
$event['_is_sold_out'] = eo_get_remaining_tickets_count( $event_id, $occurrence_id ) >0 ? 1 : 0;
and then in the JS callback check the event
object, and manipulate the DOM element accordingly. (You’ll need to do the mark-up changes client-site). I’ve not tried, but
$(element).append( '<span>sold out</span>' );
might work.
Stephen Harris