To enable to display a filter, your field needs to implement methods:
// ***
// *** CATEGORY/SEARCH FILTERING METHODS
// ***
// Method to display a search filter for the advanced search view
function onAdvSearchDisplayFilter(&$filter, $value='', $formName='searchForm')
{
if ( !in_array($filter->field_type, static::$field_types) ) return;
$this->onDisplayFilter($filter, $value, $formName, $isSearchView=1);
}
// Method to display a category filter for the category view
function onDisplayFilter(&$filter, $value='', $formName='adminForm', $isSearchView=0)
{
if ( !in_array($filter->field_type, static::$field_types) ) return;
FlexicontentFields::createFilter($filter, $value, $formName);
}
For start just try to use the default implementation (shown above):
getFiltered() // this is for category view
getFilteredSearch() // this is for search view
Default implementation is:
// Method to get the active filter result (an array of item ids matching field filter, or subquery returning item ids)
// This is for content lists e.g. category view, and not for search view
function getFiltered(&$filter, $value, $return_sql=true)
{
if ( !in_array($filter->field_type, static::$field_types) ) return;
return FlexicontentFields::getFiltered($filter, $value, $return_sql);
}
// Method to get the active filter result (an array of item ids matching field filter, or subquery returning item ids)
// This is for search view
function getFilteredSearch(&$filter, $value, $return_sql=true)
{
if ( !in_array($filter->field_type, static::$field_types) ) return;
return FlexicontentFields::getFilteredSearch($filter, $value, $return_sql);
}
these 2 methods , normally look at our flexicontent values table
but you can make them look at your table and return the FLEXIcontent item IDs that are a match
// Method to get the active filter result (an array of item ids matching field filter, or subquery returning item ids)
// This is for content lists e.g. category view, and not for search view
function getFiltered(&$filter, $value, $return_sql=true)
{
// do some work
$item_ids = array();
//
if (!is_numeric($value))
$ids[] = 51;
elseif ($value < 0 )
{
$ids[] = 4;
$ids[] = 5;
}
elseif ($value == 0 )
$ids[] = 7;
else
$ids[] = 11;
if ($value == 'test')
$ids[] = 113;
else // Do some sql query and add more
// Make sure we only have integer
JArrayHelper::toInteger($ids);
return $return_sql ? ' AND i.id IN (' . implode(',' , $ids) . ') ' : $ids;
}