I am having a little trouble when creating my own custom event list using the Eventbrite API.
I can get this to work fine when using the standard example provided here https://github.com/ryanjarvinen/eventbrite.php/blob/master/examples/event-list-example.md, but I would like to customise the layout, as well as pull some additional fields.
Here's what I have when using the above which works fine:
try {
$events = $eb_client->user_list_events();
} catch ( Exception $e ) {
// Be sure to plan for potential error cases
// so that your application can respond appropriately
//var_dump($e);
$events = array();
}
Eventbrite::eventList( $events, 'eventListRow');
However when I attempt to use the additional event list customisation example provided, no data is retrieved. Below is how I have attempted to integrate this:
$events = $eb_client->user_list_events();
$events = array();
return $this->load->view('user_list_events', $events, TRUE);
$event_list_html = Eventbrite::eventList( $events, $custom_render_function);
return $event_list_html;
My view page is:
$custom_render_function = function($evnt){
$time = strtotime($evnt->start_date);
if( isset($evnt->venue) && isset( $evnt->venue->name )){
$venue_name = $evnt->venue->name;
}else{
$venue_name = 'online';
}
$evnt_html = "<div class='eb_evnt_list_item' id='evnt_div_"
. $evnt->id ."'><span class='eb_evnt_list_date'>"
. strftime('%a, %B %e', $time) . "</span><span class='eb_evnt_list_time'>"
. strftime('%l:%M %P', $time) . "</span><a class='eb_evnt_list_title' href='"
. $evnt->url."'>".$evnt->title."</a><span class='eb_evnt_list_location'>"
. $venue_name . "</span></div>\n";
return $evnt_html;
}
I have tried multiple options, such as adding the code above where I have return $this->load->view('user_list_events', $events, TRUE); , but this returns Parse error: syntax error, unexpected '}' or Parse error: syntax error, unexpected '$event_list_html'.
Thanks in advance. Ben
UPDATE
$events = $eb_client->user_list_events();
return $this->load->view('user_list_events', Eventbrite::eventList( $events, $custom_render_function), TRUE);