Skip to content

Instantly share code, notes, and snippets.

@litzinger
Created July 31, 2012 18:49
Show Gist options
  • Save litzinger/3219428 to your computer and use it in GitHub Desktop.
Save litzinger/3219428 to your computer and use it in GitHub Desktop.
Modify Calendar module to support custom pagination hook
<?php
// ~ line 1548 of mod.calendar.php
//--------------------------------------------
// pagination for the events tag
//--------------------------------------------
// any tags using this might have different needs
// so we only want to paginate for original events
// tag usage
//--------------------------------------------
$this->paginate = FALSE;
// When on the last page of a result set pagination does not display when this is commented out.
// And the hook below needs it...
$this->event_timeframe_total = count($channel->query->result);
if ($this->parent_method === 'events' AND
$this->P->value('event_limit') > 0 AND
$this->event_timeframe_total > $this->P->value('event_limit'))
{
//get pagination info
$pagination_data = $this->universal_pagination(array(
'total_results' => $this->event_timeframe_total,
//had to remove this jazz before so it didn't get iterated over
'tagdata' => ee()->TMPL->tagdata . $this->paginate_tagpair_data,
'limit' => $this->P->value('event_limit'),
'uri_string' => ee()->uri->uri_string,
'paginate_prefix' => 'calendar_'
));
// -------------------------------------------
// 'calendar_events_create_pagination' hook.
// - Let devs maniuplate the pagination display
if (ee()->extensions->active_hook('calendar_events_create_pagination') === TRUE)
{
$pagination_data = ee()->extensions->call('calendar_events_create_pagination', $this, $pagination_data);
}
//
// -------------------------------------------
//if we paginated, sort the data
if ($pagination_data['paginate'] === TRUE)
{
$this->paginate = $pagination_data['paginate'];
$this->page_next = $pagination_data['page_next'];
$this->page_previous = $pagination_data['page_previous'];
$this->p_page = $pagination_data['pagination_page'];
$this->current_page = $pagination_data['current_page'];
$this->pager = $pagination_data['pagination_links'];
$this->basepath = $pagination_data['base_url'];
$this->total_pages = $pagination_data['total_pages'];
$this->paginate_data = $pagination_data['paginate_tagpair_data'];
$this->page_count = $pagination_data['page_count'];
//ee()->TMPL->tagdata = $pagination_data['tagdata'];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment