SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 316 | Next

James Kennard

"Mastering Joomla! 1.5 Extension and Framework Development"

We do this in
much the same way as we modified the results for the published state filter. This
example shows how we can modify the JModel _buildQueryWhere() method to
incorporate the category.
/**
* Builds the WHERE part of a query
*
* @return string Part of an SQL query
*/
function _buildQueryWhere()
{
global $mainframe, $option;
// get the filter values
$filter_state = $mainframe->getUserStateFromRequest(
>$option.'filter_state',
'filter_state');
$filter_catid = $mainframe->getUserStateFromRequest(
>$option.'filter_catid',
'filter_catid');
// prepare the WHERE clause
$where = array();
// Determine published state
if ($filter_state == 'P')
{
$where[] = 'published = 1';
}
elseif ($filter_state == 'U')
{
$where[] = 'published = 0';
}
// Determine category ID
if ($filter_catid = (int)$filter_catid)
{
$where[] = 'catid = '.$filter_catid;
}
// return the WHERE clause
return (count($where)) ? ' WHERE '.implode(' AND ', $where) : '';
}
Chapter 8
[ 237 ]
To facilitate the easiest way of building the WHERE clause we make $where an array
and implode it at the end.


Pages:
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6