protected function onBeforeBrowse()
{
// Create the lists object
$this->lists = new \stdClass();
// Load the model
/** @var DataModel $model */
$model = $this->getModel();
// We want to persist the state in the session
$model->savestate(1);
// Display limits
$defaultLimit = 20;
if (!$this->container->platform->isCli() && class_exists('JFactory')) {
$app = \JFactory::getApplication();
if (method_exists($app, 'get')) {
$defaultLimit = $app->get('list_limit');
} else {
$defaultLimit = 20;
}
}
$this->lists->limitStart = $model->getState('limitstart', 0, 'int');
$this->lists->limit = $model->getState('limit', $defaultLimit, 'int');
$model->limitstart = $this->lists->limitStart;
$model->limit = $this->lists->limit;
// Assign items to the view
$this->items = $model->get(false);
$this->itemCount = $model->count();
// Ordering information
$this->lists->order = $model->getState('filter_order', $model->getIdFieldName(), 'cmd');
$this->lists->order_Dir = $model->getState('filter_order_Dir', null, 'cmd');
if ($this->lists->order_Dir) {
$this->lists->order_Dir = strtolower($this->lists->order_Dir);
}
// Pagination
$this->pagination = new \JPagination($this->itemCount, $this->lists->limitStart, $this->lists->limit);
// Pass page params on frontend only
if ($this->container->platform->isFrontend()) {
/** @var \JApplicationSite $app */
$app = \JFactory::getApplication();
$params = $app->getParams();
$this->pageParams = $params;
}
}