Okay
  Public Ticket #1749757
Filter Calendar
Closed

Comments

  • Ellie started the conversation

    Hi,

    I showed several calendars in one page with following code and I wondered how I can set one of them as default view calendar. For example, there're 3 calendars:

    [stachethemes_ec view="month" cal=1,2,3]

    How can we define that the default view is only calendar with id#1 (so whoever wants to see cal #2 or #3 needs to go to the filter and choose them)? 

  •  799
    Zhivko replied

    Hi,

    There's no built-in option to set default calendar.

    I've written a small code that will do what you want. Place it in your theme functions.php file:

    add_action('wp_footer', function() {
        ?>
        <script type="text/javascript">
            (function ($) {
                
                if (typeof $.stecExtend !== 'function') {
                    return;
                }             var primaryCalendar = 25095; // Enter your primary calendar id number here
                var runOnce = false;             $.stecExtend(function (master) {
                    if (true === runOnce) {
                        return;
                    }
                    runOnce = true;
                    master.calData.calendarFilter = [primaryCalendar];
                    master.$instance.$top.find('.stec-top-menu-filter-by-calendar')
                            .find('li').not('[data-calid="' + primaryCalendar + '"]')
                            .each(function () {
                                $(this).removeClass('active');
                                $(this).find('i').removeClass('fas fa-square')
                                        .addClass('far fa-square');
                            });
                }, 'onAddToEventsPool');         })(jQuery);
        </script>
        <?php
    });



    Stachethemes Developer

  • Ellie replied

    It works! Thank you!