Limiting mini calendar widget initial results

Home Forums Calendar Products Events Calendar PRO Limiting mini calendar widget initial results

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1129464
    Pieter Heineken
    Participant

    Hi there,

    I posted about this topic before but wasn’t able to follow up before the post was closed. My previous post is here:

    Limiting mini calendar widget results

    I wanted to limit the number of initial results shown for the widget calendar so I could set the calendar to show say 12 results when a date selected but only show 6 at the initial load. I don’t think its the most elegant solution but I was able to accomplish this by adding $( '.tribe-mini-calendar-event' ).slice( 6 ).css( 'display', 'none' ); to the top of src/resources/js/widget-calendar.js. Now the issue is by editing this file I’m assuming this edit will be wiped out when I update the plugin. Is there a way to make this edit so it won’t be reset?

    Thanks,

    Pieter

    • This topic was modified 9 years, 11 months ago by Pieter Heineken. Reason: wrong path to file
    #1129603
    Cliff
    Member

    Hi Pieter. Thanks for your question.

    I can strongly advise against editing any of our plugin files.

    Instead, I’d suggest using wp_enqueue_script (as long as you use noconflict mode) and hooking into the tribe_events_mini_cal_list_inside_before_loop or tribe_events_mini_cal_list_inside_after_loop action (or a better-suited one depending on your needs).

    If you need some coding help, you may want to ask your developer or reference our list of known customizers.

    Please let me know if you think I may be of more help.

    #1129951
    Pieter Heineken
    Participant

    Thanks for your reply. Excuse my ignorance but why can’t I just add the script to functions.php?

    function limit_mini_calendar_results() {
    	if ( is_front_page() ) {
    	echo "
            <script type='text/javascript'>
                jQuery( document ).ready( function( $ ) {
    				$( '.tribe-mini-calendar-event' ).slice( 6 ).css( 'display', 'none' );
                } );
            </script>
    	";
    	}
    }
    add_action('wp_footer', 'limit_mini_calendar_results');
    #1129980
    Cliff
    Member

    After a quick look, I don’t see anything wrong with that code if it’s working for you, except that you’re adding that script to ALL of your site’s pages, not just when the Mini Calendar widget is on the page.

    If it’s working for you, it’s probably just fine.

    Is there anything more I can do for you on this topic?

    #1130004
    Pieter Heineken
    Participant

    From what I can tell the script is only being added to the front page which is the only instance of the mini calendar widget on the site. Thanks for your help – consider the issue resolved.

    – Pieter

    #1130083
    Cliff
    Member

    Ah, yes, that’s correct due to the use of the is_front_page() conditional.

    I’m glad things are working as you desire!

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Limiting mini calendar widget initial results’ is closed to new replies.