Hello
I have a issue, I update my joomla from 1.5 to 3, and update flexicontent too. I follow the steps, no problem to there.
The issue comes last week, when I create a new article, use relation field, associate to others, and when I filter, this new items dont show on results.
I send to you, a piece of code to use on relations field, to be filtrable.
The old items are ok, the new one, do not filter.
Any ideas?
PS: I found the possible problem (Attachment). The relation add item:cat, so he cant find on category
PS2: I dont want add this :cat on the value. How I can change this? (This solution is only for this project)
PS3: the possible solution for this problem,without change much code, is in mysql, add :catid, and in relation.php, add some line of code, to create a same value as have in BD
Code:
function onDisplayFilter(&$filter, $value='', $formName='adminForm', $isSearchView=0)
{
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();
$catId = 'SELECT catid'
.' FROM #__flexicontent_cats_item_relations'
.' WHERE itemid='.$results[0]->value;
$db->setQuery($catId);
$theCategory = $db->loadObjectList();
/*echo "<pre>";
print_r($theCategory[0]->catid);
echo "</pre>";*/
if (!$results) {
$filter->html = '';
} else {
$options = array();
$options[] = JHTML::_('select.option', '', '-'.JText::_('FLEXI_SEARCH_ANY').'-');
foreach($results as $result) {
$options[] = JHTML::_('select.option', $result->value.':'.$theCategory[0]->catid, $result->text);
}
//$filter->html = JHTML::_('select.genericlist', $options, 'filter_'.$filter->id, 'onchange="document.getElementById(\'adminForm\').submit();"', 'value', 'text', $value);
$filter->html = JHTML::_('select.genericlist', $options, 'filter_'.$filter->id, 'onchange="document.getElementById(\'adminForm\').submit();"', 'value', 'text', $value);
}
}
For every field:
Code:
SELECT * FROM `j25_flexicontent_fields_item_relations` WHERE field_id=28
UPDATE `j25_flexicontent_fields_item_relations` SET `value`= CONCAT(value,':35') WHERE field_id=28
UPDATE `j25_flexicontent_fields_item_relations` SET value = SUBSTRING_INDEX(value, ':35', 2) WHERE field_id=28