Reputation: 31
How can I modify the following call so upcoming events show up first. Currently the order is very random; I need to show most current events at the top and any past events should not be showing...
<div class="events-links">
<?
include "eventbrite/Eventbrite.php";
$authentication_tokens = array('app_key' => 'APP_KEY',
'user_key' => 'USER_KEY');
$eb_client = new Eventbrite( $authentication_tokens );
$events = $eb_client->user_list_events();
?>
<span class="inspirational">Upcoming Events</span>
<?= Eventbrite::eventList( $events, 'eventListRow'); ?>
</div>
Upvotes: 0
Views: 467
Reputation: 169
If you're using the user_list_events
method, you can filter your results by adjusting the event_statuses
field. Valid options include: live, started, or ended. To display only upcoming events, for example: event_statuses=live
.
The results will display from soonest upcoming event to event happening farthest in the future.
Upvotes: 2
Reputation: 27247
After you fetch $events
, use usort
to sort the array.
usort: http://php.net/manual/en/function.usort.php
$events = $eb_client->user_list_events();
usort($events, function($a, $b) {
$adate = $a->start // or $a['date'] or $a->whatever it is
$bdate = $b->start // or $a['date'] or $a->whatever it is
if ($adate < $bdate) return -1;
if ($adate > $bdate) return 1;
return 0;
});
Alternatively, you can contact your account manager if you have one.
(Disclosure: I work for an EB competitor)
Upvotes: 1