Home › Forums › Calendar Products › Events Calendar PRO › Change starting month in table-mini.php
- This topic has 14 replies, 4 voices, and was last updated 10 years, 9 months ago by
Support Droid.
-
AuthorPosts
-
December 14, 2012 at 2:27 pm #29532
Jason
ParticipantI’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.December 14, 2012 at 7:55 pm #29560Barry
MemberHi 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!
December 16, 2012 at 3:14 pm #29599Jason
ParticipantThanks 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
December 16, 2012 at 8:02 pm #29601Barry
MemberYes, 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.
December 19, 2012 at 9:21 am #29775Jason
ParticipantHi 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’;
}
}December 19, 2012 at 12:11 pm #29783Barry
MemberNo problem, glad you’re all sorted here and thanks for reporting back 🙂
December 23, 2012 at 1:29 pm #29962Will
ParticipantJason and Barry–thank you so much for this, perfect.
December 23, 2012 at 1:40 pm #29965Will
ParticipantActually, 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?
December 23, 2012 at 2:06 pm #29966Will
ParticipantActually: 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/0YKGPzbEDecember 23, 2012 at 2:10 pm #29967Will
ParticipantEDIT: 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.
December 23, 2012 at 2:13 pm #29968Will
ParticipantOK fixed it. Forgot the query_vars…
http://pastebin.com/N2zbKRcMDecember 24, 2012 at 11:32 am #29975Barry
MemberHi Will: are you sorted here/need any further input?
December 27, 2012 at 9:30 pm #30052Will
ParticipantI’m all sorted here.
December 28, 2012 at 6:19 am #30064Barry
MemberGreat, thanks!
July 7, 2015 at 6:26 am #978358Support Droid
KeymasterThis 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. -
AuthorPosts
- The topic ‘Change starting month in table-mini.php’ is closed to new replies.
