I wanted to enable the “filter category views” (by language) option on my site, with items that had a published JoomFish translation included amongst the results along with any items identified in FlexiContent as being in the currently selected language. This is not how FlexiContent currently behaves, so I modified
components/com_flexicontent/models/category.php to add the necessary logic, and I suggest that this should be the actual behaviour of the “filter category views” option.
Here are the changes I made (context / logic based on v1.5.6 RC1 r967
and v2.0 RC1 r967, and should work with both):
In the file listed above, in the _buildQuery() function, above this line:
Code:
$query = 'SELECT DISTINCT i.*, ie.*, u.name as author, ty.name AS typename,'
, I added:
Code:
if (defined('JOOMFISH_PATH') && FLEXI_FISH && $this->_category->parameters->get('filtercat', 0)) {
$jf_join = ' LEFT JOIN #__jf_content as jfc ON jfc.reference_id = i.id'
. ' LEFT JOIN #__languages as jfl ON jfc.language_id = jfl.id';
}
else {
$jf_join = '';
}
then in the actual creation of the $query string, above the beginning of the ‘where’ part of the query:
, I concatenate the string created above to the $query string:
The second part of the change comes in the _buildItemWhere() function, within the
if (FLEXI_FISH && $filtercat) { block that comes after this comment: "// Filter the category view with the active active language". I replaced the existing line with one that checks if the language is like $lang OR if it has a published translation in the language $lang (note that the second part of that condition only gets checked if joomfish is currently active [i.e.,
if (defined('JOOMFISH_PATH'))):
Code:
if (FLEXI_FISH && $filtercat) {
$where .= ' AND (ie.language LIKE ' . $this->_db->Quote( $lang .'%' );
if (defined('JOOMFISH_PATH'))
$where .= ' OR jfc.reference_table="content" AND jfc.published=1 AND jfl.shortcode=' . $this->_db->Quote($lang);
$where .= ')';
}
And that’s everything! To me, this seems to be a better, more complete Joomfish integration; if a user has decided to use Joomfish and wants to filter by language, wouldn’t they want translations in the current language to be included?
I hope that is clear, and that the developers will consider including this in the flexicontent core. Thanks!