We don't have to format the filter in this way, and
for those of us who prefer a good dose of CSS, it is perfectly acceptable to implement
a table-less design.
The next question is: How do we apply a filter? This is far easier than it might sound.
When we discussed ordering we described the _buildQuery() method in the model.
It's back to that method to make some more changes:
/**
* Builds a query to get data from #__sometable
*
* @return string SQL query
*/
function _buildQuery()
{
return ' SELECT * '
. ' FROM #__sometable '
. $this->_buildQueryWhere()
. $this->_buildQueryOrderBy();
}
This time we have a call to the _buildQueryWhere() method. This method works in
much the same way as the _buildQueryOrderBy() method except that it returns a
WHERE clause instead of an ORDER BY clause.
This example demonstrates how we can implement this method in order to apply the
published state filter:
/**
* Builds the WHERE part of a query
*
* @return string Part of an SQL query
*/
function _buildQueryWhere()
{
global $mainframe, $option;
// get the filter published state value
$filter_state = $mainframe-
>getUserStateFromRequest($option.
Pages:
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324