Ordering and search, no pagination yet
This commit is contained in:
@ -18,6 +18,28 @@ use Joomla\Database\ParameterType;
|
||||
|
||||
class PackagesModel extends ListModel
|
||||
{
|
||||
public function __construct($config = [])
|
||||
{
|
||||
$config['filter_fields'] = [
|
||||
'id',
|
||||
'p.id',
|
||||
'name',
|
||||
'p.name',
|
||||
'alias',
|
||||
'p.alias',
|
||||
'state',
|
||||
'p.state',
|
||||
'published',
|
||||
'p.published',
|
||||
'mounting_style_id',
|
||||
'p.mounting_style_id',
|
||||
'mounting_style',
|
||||
'description',
|
||||
'p.description',
|
||||
];
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build an SQL query to load the list data.
|
||||
*
|
||||
@ -81,6 +103,11 @@ class PackagesModel extends ListModel
|
||||
$query->where($db->quoteName('p.state') . ' IN (0, 1)');
|
||||
}
|
||||
|
||||
// add list ordering clause
|
||||
$orderCol = $this->state->get('list.ordering', 'id');
|
||||
$orderDirn = $this->state->get('list.direction', 'asc');
|
||||
$query->order($db->escape($orderCol) . ' ' . $db->escape($orderDirn));
|
||||
|
||||
return $query;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user