Ordering and search, no pagination yet
This commit is contained in:
@ -18,6 +18,30 @@ use Joomla\Database\ParameterType;
|
||||
|
||||
class ManufacturersModel extends ListModel
|
||||
{
|
||||
public function __construct($config = [])
|
||||
{
|
||||
$config['filter_fields'] = [
|
||||
'id',
|
||||
'm.id',
|
||||
'name_short',
|
||||
'm.name_short',
|
||||
'name_long',
|
||||
'm.name_long',
|
||||
'alias',
|
||||
'm.alias',
|
||||
'state',
|
||||
'm.state',
|
||||
'published',
|
||||
'm.published',
|
||||
'description',
|
||||
'm.descrition',
|
||||
'image',
|
||||
'm.image',
|
||||
];
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Build an SQL query to load the list data.
|
||||
*
|
||||
@ -79,6 +103,11 @@ class ManufacturersModel extends ListModel
|
||||
$query->where($db->quoteName('m.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