Category language filter including JoomFish translations

6 years 9 months ago #20902 by andrew
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:
$query = 'SELECT DISTINCT i.*, ie.*, u.name as author, ty.name AS typename,'
, I added:
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:
. $where
, I concatenate the string created above to the $query string:
. $jf_join

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'))):
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!

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

6 years 9 months ago #20909 by ggppdk
Thanks, good idea, just in v1.5.7 we will have full items translations associated with the original item, plus Google translation and Joomfish data import

but i have opened an enhancement issue to examine your code:

http://code.google.com/p/flexicontent/i ... ail?id=289


-- 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 review. Thanks!

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

6 years 9 months ago #20914 by andrew
Great, thanks for the quick response. Making item translations native to flexicontent sounds like an ideal solution for multi-language websites. I hope that goes well.

And thanks also for opening an issue to consider the code I suggested, I hope some version of it makes it in. I think it would help others who still decide, for whatever reason, to use joomfish (e.g. if they only want one interface to translate all of their content, including modules, menu items, contacts, etc.).

Cheers!

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

5 years 7 months ago #33144 by klas
HUH, this really saved my day.

I implemented it also in the module (getItems method in the helper), code is almost the same except that if needs to check for $method_curlang == 2 instead of $filtercat, where part comes in the begging of the method, after
} else if ($method_curlang == 2) { // include method  ---  include items of current language ONLY
and join part is added to the query at the end of the method

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

Moderators: vistamediajoomlacornerggppdk
© 2018 Flexicontent. All Rights Reserved.