Reworked the events paginate function, it now grabs only the needed fields, sorts properly, and limits based on the configured ZM_WEB_EVENTS_PER_PAGE option.

This commit is contained in:
Kyle Johnson 2013-05-15 17:46:11 -04:00
parent c47f450e41
commit 4022695961
1 changed files with 6 additions and 5 deletions

View File

@ -4,16 +4,17 @@ class EventsController extends AppController {
public $helpers = array('Paginator');
public $components = array('Paginator');
public $paginate = array(
'limit' => 25,
'order' => array( 'Event.Id' => 'asc'
)
);
$this->loadModel('Monitor');
$this->loadModel('Config');
$events_per_page = $this->Config->find('first', array('conditions' => array('Name' => 'ZM_WEB_EVENTS_PER_PAGE'), 'fields' => 'Value'));
public function index() {
$this->paginate = array(
'fields' => array('Event.Name', 'Event.Length', 'Event.MonitorId', 'Event.Id', 'Monitor.Name'),
'limit' => $events_per_page['Config']['Value'],
'order' => array( 'Event.Id' => 'asc')
);
$data = $this->paginate('Event');
$this->set('events', $data);
$options = array('fields' => array('DISTINCT Monitor.Id'));