Hi..
I have a question? Is possible use FC Relation field and Relation reversed like a filter? :shock:
Code:
//CAT FILTER
// *********************************
// CATEGORY/SEARCH FILTERING METHODS
// *********************************
// Method to display a search filter for the advanced search view
function onAdvSearchDisplayFilter(&$filter, $value='', $formName='searchForm')
{
// execute the code only if the field type match the plugin type
if ( !in_array($filter->field_type, self::$field_types) ) return;
self::onDisplayFilter($filter, $value, $formName, $elements=true);
}
function onDisplayFilter(&$filter, $value='', $formName='adminForm')
{
// execute the code only if the field type match the plugin type
//if($filter->field_type != 'selectflexiitem') return;
if ( !in_array($filter->field_type, self::$field_types) ) return;
// some parameter shortcuts
$db =& JFactory::getDBO();
$field_elements= 'SELECT DISTINCT id as value, title as text'
.' FROM #__content as i'
.' LEFT JOIN #__flexicontent_fields_item_relations as fir ON i.id=fir.value'
.' WHERE fir.field_id='.$filter->id.' Order by text ASC'
;
$query = preg_match('#^select#i', $field_elements) ? $field_elements : '';
$db->setQuery($query);
$results = $db->loadObjectList();
if (!$results) {
$filter->html = '';
} else {
$options = array();
$options[] = JHTML::_('select.option', '', '-'.JText::_('All').'-');
foreach($results as $result) {
$options[] = JHTML::_('select.option', $result->value, $result->text);
}
$filter->html = JHTML::_('select.genericlist', $options, 'filter_'.$filter->id, 'onchange="document.getElementById(\'adminForm\').submit();"', 'value', 'text', $value);
}
}
// 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)
{
// execute the code only if the field type match the plugin type
if ( !in_array($filter->field_type, self::$field_types) ) return;
return FlexicontentFields::getFiltered($filter, $value, $return_sql=true);
}
// 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)
{
if ( !in_array($filter->field_type, self::$field_types) ) return;
$filter->isindexed = true;
return FlexicontentFields::getFilteredSearch($filter, $value, $return_sql=true);
}