Okay
  Public Ticket #1895250
Add address to boxgrid
Closed

Comments

  • Rodolphe1150 started the conversation

    Hello,

    I love the "boxgrid" view for the event, but sadly the address of the event doesn't show on the "boxgrid" view (while the "grid" view does it).


    There are a way to show the address directly on the "boxgrid" view?

  •  877
    Zhivko replied

    Hi,

    Try following:

    Open your theme functions.php file and at the bottom add:

    add_action('wp_footer', function() {
        ?>
        <script type="text/javascript">
            (function ($) {             if (typeof $.stecExtend !== 'function') {
                    return;
                }             $.stecExtend(function (m) {
                    if (m.glob.options.view === 'boxgrid') {                     m.$instance.$boxgrid.find('.stec-layout-boxgrid-event').each(function () {
                            var id = parseInt($(this).attr('data-id'), 10);
                            var event = m.calData.getEventById(id);
                            if (event.location) {
                                var html = '<span class="stec-layout-boxgrid-event-location">' + event.location + '</span>';
                                $(html).insertAfter($(this).find('.stec-layout-boxgrid-event-title'));
                            }
                        });
                    }
                }, 'onLayoutSet');
            })(jQuery);
        </script>
        <?php
    });



    Stachethemes Developer

  • Rodolphe1150 replied

    Thanks!

    It's work fine for the first results. But for the results that appears after clicking on "show more", addresses are NOT shown on the new results.

    Did you see a way to apply this change at all my events?

    My page: https://www.pickactivity.com/agenda-kids-family/

  •  877
    Zhivko replied

    Replace the old code with this one:

    add_action('wp_footer', function() {
        ?>
        <script type="text/javascript">
            (function ($) {
                if (typeof $.stecExtend !== 'function') {
                    return;
                }
                $.stecExtend(function (m) {
                    if (m.glob.options.view === 'boxgrid') {
                        m.$instance.$boxgrid.find('.stec-layout-boxgrid-event').each(function () {
                            var id = parseInt($(this).attr('data-id'), 10);
                            var event = m.calData.getEventById(id);
                            if (event.location) {
                                var html = '<span class="stec-layout-boxgrid-event-location">' + event.location + '</span>';
                                $(html).insertAfter($(this).find('.stec-layout-boxgrid-event-title'));
                            }
                        });
                    }
                }, 'onLayoutSet');             $.stecExtend(function (m) {                 m.$instance.$boxgrid.find('.stec-layout-boxgrid-events-all-load-more').on('click', function () {
                        m.$instance.$boxgrid.find('.stec-layout-boxgrid-event').each(function () {
                            
                            if ($(this).find('.stec-layout-boxgrid-event-location').length > 0) {
                                return true; //continue
                            }
                            
                            var id = parseInt($(this).attr('data-id'), 10);
                            var event = m.calData.getEventById(id);
                            if (event.location) {
                                var html = '<span class="stec-layout-boxgrid-event-location">' + event.location + '</span>';
                                $(html).insertAfter($(this).find('.stec-layout-boxgrid-event-title'));
                            }
                        });
                    });             });         })(jQuery);
        </script>
        <?php
    });

    Stachethemes Developer

  • Rodolphe1150 replied

    Perfect! Thank you very much.