Skip to content

Instantly share code, notes, and snippets.

@kylejohnson
Last active December 17, 2015 20:19
Show Gist options
  • Select an option

  • Save kylejohnson/5667134 to your computer and use it in GitHub Desktop.

Select an option

Save kylejohnson/5667134 to your computer and use it in GitHub Desktop.
<?php
class EventsController extends AppController {
public $helpers = array('Paginator');
public $components = array('Paginator', 'RequestHandler');
public function index() {
$this->loadModel('Monitor');
$this->loadModel('Config');
if($this->params['named']['MonitorId']) {
$monitor_id = $this->params['named']['MonitorId'];
$conditions = array("MonitorId = $monitor_id");
};
$events_per_page = Configure::read('ZM_WEB_EVENTS_PER_PAGE');
$this->paginate = array(
'fields' => array('Event.Name', 'Event.Length', 'Event.MonitorId', 'Event.Id', 'Monitor.Name'),
'limit' => $events_per_page,
'order' => array( 'Event.Id' => 'asc'),
'conditions' => $conditions
);
$data = $this->paginate('Event');
$this->set('events', $data);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment