Home › Forums › Calendar Products › Events Calendar PRO › Costum monthly list going down from current month back to 2009.
- This topic has 5 replies, 4 voices, and was last updated 9 years, 10 months ago by
sven.
-
AuthorPosts
-
May 27, 2016 at 5:59 am #1119652
sven
ParticipantHi everyone,
what I am trying to achieve is a list that goes down from current month in current year (so 2016-05) back to 2009-01 and displays the certain events of each month in a sort of list-display.
What I have is this:
http://pastebin.com/9e5U1g7QUnfortunately something in the tribe_get_events is massively wrong. It always calls ALL events and not only the events for the certain specific $year and $month, resulting showing all events from 2016 back until 2009 for 2016-05, 2016-04, 2016-03 … 2015-12, 2015-11 and so on.
I can’t find any help in the tribe_get_events documentation but guess that is has to do with the lines of start_date, end_date and eventDisplay.
Can anyone help me?
That would be greatly appreciated.Best
May 27, 2016 at 6:06 am #1119659sven
ParticipantSorry, old pastebin, here is the current script:
http://pastebin.com/bQarcxwuMay 27, 2016 at 4:29 pm #1119963George
ParticipantHey @Sven,
Thank you for reaching out! I am sorry to bear this news, but we unfortunately cannot provide the sort of code-level support you are looking for here. We are not able to help with any custom coding. 🙁
You can read more about this here ? https://theeventscalendar.com/knowledgebase/what-support-is-provided-for-license-holders/
I’m sorry to disappoint!
Sincerely,
GeorgeMay 27, 2016 at 4:41 pm #1119964George
ParticipantWhile what I wrote in my above reply is true, and we will not be able to help you see this customization through to completion, I did just want to chime in a bit and at least offer some general advice! 😉
One thing I think will make a huge difference here is how you are currently working with dates.
If you are trying to do things with dates like subtract months and years, etc., which you are doing, then I would not recommend the manual, literal approach you are currently using.
I would instead recommend getting more familiar with PHP’s DateTime object methods, which you can learn about here:
• http://php.net/manual/en/class.datetime.php
You can do things like this with that Class and its utilities:
$date_one = new DateTime( '2009-09-01' );
$date_two = new DateTime( '2016-05-27' );$time_since = $date_two->diff( $date_one );
You can then see the values you get in that $time_since variable by using print_r(), for example:
print_r( $time_since );How is this different? Well, it ensures consistency in the handling of subtracting dates from other dates; your current approach looks prone to bugs and inconsistent behavior to me after a quick read-through, so instead of doing all of the calculations manually yourself, I would recommend letting DateTime handle most of the work and then doing some simpler logic from there.
Next, when it comes to passing a Start Date and End Date to the tribe_get_events() function, I would recommend ensuring these values are the same format. A simple way of doing this is using PHP’s built-in strtotime() function, for example, which converts the passed dates to a Unix timestamp. That works well with the tribe_get_events() function.
So, something like this:
'start_date' => strtotime( '01 September 2009' ),
'end_date' => strtotime( 'now' )
Read more here ? http://php.net/manual/en/function.strtotime.php
The last thing I can recommend is to make sure your PHP syntax is correct. For example, you currently have this:
'eventDisplay' => PASTBut PAST is not defined as a constant, so you cannot use this current notation with no quotes around it, for example. So you need to replace it with this instead:
'eventDisplay' => 'past'
You will have to take the reins from here, for reasons elaborated upon in this article. But I hope these insights help!
If you would like to hire some professional developers for further code-level assistance, we have a list of great developers here → http://m.tri.be/18k1 (and we have no affiliation with any of these folks–they’re simply some well-respected names in the community that we’ve compiled).
Cheers,
GeorgeJune 11, 2016 at 9:35 am #1125642Support 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 ‘Costum monthly list going down from current month back to 2009.’ is closed to new replies.
