Posted: January 19, 2021 at 9:01 am
Hi, I am forking the latest grid-view-template addon to fit my client’s needs. For any event on the grid, I want to display the earliest (first) datetime, as well as the last datetime. For instance: Event X datetimes: Expected output: 19 January 2021 – 30 January 2021 Now, looking at the espresso-grid-template.template.php file, I can see the datetime variable is initialized with the datetimes array (line 37). My first thought was that I could find the last datetime in this array, but having had a look at the array, it seems that’s not the right approach. Here is the original EE code which I believe can be tweaked to access the last datetime of any given event:
$datetime = end( $datetimes ); $startdate = date_i18n( $date_format . ' ' . $time_format, strtotime( $datetime->start_date_and_time('Y-m-d', 'H:i:s') ) ); Could you help me figure out how to access the last datetime of a given event? Thanks! |
|
Can’t edit, but here is a much better formatting of the code on pastebin: |
|
Hi there, If you take a look at the
So if you remove the Another option is to use the helper methods we have for pulling in the ‘earliest’ and ‘latest’ datetimes from the event:
(Note that both are ordered by DTT_EVT_Start, meaning the start date set on the datetime) |
|
This makes sense! I was wondering if it had to do with that argument. Thank you I will try that and hopefully get it to work! Is there any part of the documentation which details the functions and their arguments? Or maybe a file in the core which has all the core definitions in there? Just for future reference. I had a look in the developer portal but no luck! |
|
Not currently no, we don’t have a full list of all of the method available within Event Espresso at this time. Have you read through the docs on the model system? https://github.com/eventespresso/event-espresso-core/tree/master/docs/G–Model-System Learning how that model system works means you don’t need to rely on specific functions etc. For example, the above helper functions I gave you are just using the model system to pull the information in for you. A quick example of
It’s pulling in the EE_Event model object, then using the get_many_related() method to pull in related Datetimes based on the query args passed in. The only difference between that function and
So learning how to use those models will be much more beneficial to you than specific functions as we won’t have specific functions for everything you want to do, but 99% of it you’ll already be able to do using the models. |
|
The support post ‘Grid view: last datetime’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.