[Added v3 BETA] FC version 2.2.0 - Related like filter

More
10 years 4 months ago #52690 by tevez15
Hi..

I have a question? Is possible use FC Relation field and Relation reversed like a filter? :shock:

PS: Whatever, I solved the problem :P
Probably, you dont need use all of this..
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); }

Please Log in or Create an account to join the conversation.

More
10 years 4 months ago #52694 by micker
it's maybe a good code but can you create a pull request to gihtub => more easier for help georgios

FLEXIcontent is Free but involves a very big effort on our part.
Like the our support? (for a bug-free FC, despite being huge extension) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing reviews. Thanks![/size]

Please Log in or Create an account to join the conversation.

More
10 years 4 months ago #52696 by tevez15

Please Log in or Create an account to join the conversation.

More
10 years 3 months ago #52992 by ggppdk
Hello

this should do a better job
-- it will allow
a. to do item counting properly
b. allow different displays for the field, e.g. display as checkboxes, radio-set, drop-down select

Code:
function onDisplayFilter(&$filter, $value='', $formName='adminForm', $isSearchView=0) { if ( !in_array($filter->field_type, self::$field_types) ) return; // WARNING: we can not use column alias in from, join, where, group by, can use in having (some DB e.g. mysql) and in order by // partial SQL clauses $filter->filter_valuesselect = ' i.id AS value, i.title AS text'; $filter->filter_valuesjoin = null; // use default $filter->filter_valueswhere = null; // use default // full SQL clauses $filter->filter_groupby = null; // use default, which is 'value' $filter->filter_having = null; // use default $filter->filter_orderby = null; // use default, no ordering done to improve speed, it will be done inside PHP code FlexicontentFields::createFilter($filter, $value, $formName); }


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.283 seconds
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline
Save