Change starting month in table-mini.php

Home Forums Calendar Products Events Calendar PRO Change starting month in table-mini.php

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #29532
    Jason
    Participant

    I’d like to change the starting month to be April 2013 for my sidebar calendar widget until April begins and have it behave normally after that.

    I’ve tried using the below code on line 24 of table-mini.php, which loads the month to April 2013, but prevents the events from loading and disables the previous & next month buttons.
    if ( $current_date < '2013-04-01' ) { $current_date = '2013-04-01'; }
    I'd greatly appreciate if someone could tell me what I'm doing wrong here as it feels like I'm close to a solution.

    #29560
    Barry
    Member

    Hi Jason: good question! Here’s something you could try out. First, find the following line of code (in your custom table-mini.php template):

    $eventPosts = tribe_get_events(array( 'eventDisplay'=>'month' ) );

    Add a little space above that line and add the following code:

    /**
    * Let's force the widget to default to a specific month on the initial view.
    * We assume if the request isn't ajax that it is indeed the initial view.
    */
    if (!defined('DOING_AJAX')) {
    $current_date = $wp_query->query_vars['eventDate'] = '2013-04-01';
    }

    Let me know how you get on!

    #29599
    Jason
    Participant

    Thanks Barry, the code you provided is working perfectly.
    Will this need to be removed after April so the calendar loads normally in May & beyond?

    Thanks,

    Jason

    #29601
    Barry
    Member

    Yes, at least my version would – but you could add in a comparison (like you suggested in your initial post) to negate that, ie, if this month is April 2013 or earlier then modify the start date.

    #29775
    Jason
    Participant

    Hi Barry,

    Thanks for clarifying that. I’ve setup a comparison to check for the current month and I’m copying the updated code below in case it’s useful for anyone else.

    /**
    * Let’s force the widget to default to a specific month on the initial view.
    * We assume if the request isn’t ajax that it is indeed the initial view.
    */
    if (!defined(‘DOING_AJAX’)) {
    if ( $current_date query_vars[‘eventDate’] = ‘2013-04-01’;
    }
    }

    #29783
    Barry
    Member

    No problem, glad you’re all sorted here and thanks for reporting back 🙂

    #29962
    Will
    Participant

    Jason and Barry–thank you so much for this, perfect.

    #29965
    Will
    Participant

    Actually, Jason, question for you: did pasting your code in drop some punctuation? I’m looking at it and I’m not quite understanding how the code can work with an open paranthesis and no closing one. Mind pasting in the complete set of code for this?

    #29966
    Will
    Participant

    Actually: don’t worry about it. For anyone who is using Advanced Custom Fields with the “Options” page, this is now set up to grab a custom date field from the options page called “Mini Calendar Default Month Display” and use that date as the default mini calendar start date. If no option exists, or if the current date is gte current date, it shows the current month instead.
    http://pastebin.com/0YKGPzbE

    #29967
    Will
    Participant

    EDIT: crap, for some reason this isn’t actually working, as the mini calendar isn’t actually showing any events that should be displayed on the days of this month that has events, until I click back a month, then click forward a month. So for now, ignore that pastebin until I comment back.

    #29968
    Will
    Participant

    OK fixed it. Forgot the query_vars…
    http://pastebin.com/N2zbKRcM

    #29975
    Barry
    Member

    Hi Will: are you sorted here/need any further input?

    #30052
    Will
    Participant

    I’m all sorted here.

    #30064
    Barry
    Member

    Great, thanks!

    #978358
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 15 posts - 1 through 15 (of 15 total)
  • The topic ‘Change starting month in table-mini.php’ is closed to new replies.