Category checkbox instead of dropdown to allow multiple selections.

WordPress Event Management, Calendars & Registration Forums General Question Category checkbox instead of dropdown to allow multiple selections.

This topic contains 6 replies, has 3 voices, and was last updated by  Stephen Harris 8 years, 10 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #17073

    Is there a way to change the category dropdown for the search or Calendar filter to checkboxes so we can select multiple categories?

    Please let me know how it’s possible.

    Thanks

    Mehrdad Emami
    #17076

    It can be done with the calendar with the following JavaScript:

    jQuery( 'document' ).ready(function($){
    if ($(".eo-fullcalendar").length > 0) {
        var terms = eventorganiser.fullcal.categories;  
    
        var term, html = "<ul class='eo-cal-checkboxes'>";
        for ( var term_id in terms ){
            term = terms[term_id];
            html = html + "<li><input type='checkbox' checked=checked value='"+term.slug+"'>"+term.name+"</li>";
        }
        var html = html + "</ul>";
    
        $( '.eo-fullcalendar' ).each( function(){
            $(this).append( html );
        });
    
        $( '.eo-cal-checkboxes' ).on( 'click', function(){
            $(".eo-fullcalendar").fullCalendar("rerenderEvents");   
        });
    
        wp.hooks.addFilter( 'eventorganiser.fullcalendar_render_event', function( render, event, eventView, inst ){
    
            var selected = $(inst.calendar.options.id).find(".eo-cal-checkboxes input:checkbox:checked").map(function(){
                  return $(this).val();
            }).get();
    
            var intersect = $.map( event.category, function( event_cat ){
                return $.inArray( event_cat, selected ) < 0 ? null : event_cat;
            });
    
            return ( intersect.length > 0 );
        } );
    
    }
    });
    

    You can either add that to the bottom of frontend.js (and frontend.min.js) – but keep in mind that changes made to plug-ins are lost when you update that plug-in. Alternatively you could load that javascript from a separate file.

    Stephen Harris
    #17096

    Alright, I tried the code and it successfully added the category check boxes but they appear after the calendar. I need them on top.

    Most importantly the category filtering had stopped working on my calendar even before I switched to checkboxes.

    So can you help me figure out why the category filtration doesn’t work by default?

    Thanks

    Mehrdad Emami
    #17126

    Just sent you an e-mail regarding this.

    Stephen Harris
    #17127

    hm. I got your message about the other one but not this one I think.

    Mehrdad Emami
    #22569

    Hi. I’d like to add the checkboxes, too. Is the code/solution above still valid? Thank you.

    Brian O’Neill
    #22596

    Hi Brian,

    Yes it is – although it doesn’t handle events without a category (i.e., such events do not appear).

    Stephen Harris
Viewing 7 posts - 1 through 7 (of 7 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.