Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

All other Modules

Discuss all other Modules here.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

event calendar with pagination?


Reply

6 Posts   2000 Views

Avatar
marcink

26 April 2009 at 10:23pm Community Member, 89 Posts

hi,

how can i enable pagination for the calendar?

thanks

Avatar
UncleCheese

28 April 2009 at 1:16am 4085 Posts

It's not supported yet, but assuming you have your own Calendar subclass, you can just overload the Events() method.

public function Events( args... )
{
$events = parent::Events(args.. );
$per_page = 10;
if(!isset($_REQUEST['start'])) $_REQUEST['start'] = 0;
return $events->getRange($_REQUEST['start'], $per_page);
}

Avatar
marcink

28 April 2009 at 5:06am Community Member, 89 Posts

hi unclecheese,

thanks a lot, you're very helpful!

Avatar
marcink

2 May 2009 at 4:01am Community Member, 89 Posts

can i use

setPageLimits() or setPageLength()

on the $events in the overloading Events()?

because when i tried

public function Events( )
{
$events = parent::Events( );
$per_page = 10;
if(!isset($_REQUEST['start'])) $_REQUEST['start'] = 0;
$events->setPageLimits($_REQUEST['start'], $per_page, $events->Count());
return $events;
}

i got the right paging info, but all of the events at once. when using getRange(), i got the correct number of events, but no paging info...

thanks

Avatar
Digital-Punk.co.uk

12 March 2010 at 3:45am Community Member, 51 Posts

Hi there

does anybody got correct pagination of dataobjectset with "setPageLimits"? At the moment I have exactly the same problem like "marcink".

Any help please!

Best regards
Digital Punk

Avatar
Gene

21 September 2010 at 9:41am (Last edited: 21 September 2010 9:42am), Community Member, 41 Posts

You need to use both getRange and setPageLimits. Just make sure to use setPageLimits after getRange because getRange returns a new dataobjectset.

public function Events($filter = null, $start_date = null, $end_date = null, $default_view = false, $limit = null, $announcement_filter = null) {
      $events = parent::Events($filter, $start_date, $end_date, $default_view, $limit, $announcement_filter);
      
      $perPage = 20;
      if(!isset($_GET['start']) || !is_numeric($_GET['start']) || (int)$_GET['start'] < 1) $_GET['start'] = 0;
      $start = (int) $_GET['start'];
      $totalSize = $events->Count();
      
      $limitedEvents = $events->getRange($start, $perPage);
      $limitedEvents->setPageLimits($start, $perPage, $totalSize);
      
      return $limitedEvents;
   }