Create the following files:
plugins/system/autoselectlang.php
Code:
<?php
// Check to ensure this file is included in Joomla!
defined( '_JEXEC' ) or die( 'Restricted access' );
$mainframe->registerEvent('onAfterRoute', 'botAutoSelectLang');
function botAutoSelectLang( $args ) {
if (JRequest::getVar('option') == 'com_flexicontent') {
if ($aid = JRequest::getInt('id', 0)) {
global $mainframe;
$lang = $mainframe->getUserState('application.lang');
$db =& JFactory::getDBO();
$query = 'SELECT j.id, ie.language'
. ' FROM #__content AS i'
. ' INNER JOIN #__content AS j ON i.alias = j.alias AND i.catid = j.catid AND i.state = 1'
. ' LEFT JOIN #__flexicontent_items_ext AS ie ON ie.item_id = j.id'
. ' WHERE i.id = ' .(int) $aid
;
$db->setQuery($query);
$items = $db->loadObjectList();
foreach($items as $item) {
if(substr($item->language, 0, 2) == substr($lang, 0, 2)) {
JRequest::setVar('id', $item->id);
break;
}
}
}
}
}
?>
plugins/system/autoselectlang.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<install version="1.5.0" type="plugin" group="content">
<name>Auto Language Selection</name>
<author>Caesar KAN</author>
<creationDate>January 2010</creationDate>
<copyright>Copyright (C) 2010 Orderly Software. All rights reserved.</copyright>
<license></license>
<authorEmail>ckan@as05.com</authorEmail>
<authorUrl></authorUrl>
<version>1.0.0</version>
<description>Displays Flexicontent article of the current language.</description>
<files>
<filename plugin="autoselectlang">autoselectlang.php</filename>
</files>
<params>
</params>
</install>
Register the plugin:
INSERT INTO `jos_plugins` (`id`, `name`, `element`, `folder`, `access`, `ordering`, `published`, `iscore`, `client_id`, `checked_out`, `checked_out_time`, `params`) VALUES
(68, 'System - Auto language Selection', 'autoselectlang', 'system', 0, 0, 1, 0, 0, 0, '0000-00-00 00:00:00', '')
Comment out the following lines in components/com_flexicontent/views/items/view.html.php:
Code:
//special to hide the joomfish language selector on item views
//$css = '#jflanguageselection { visibility:hidden; }';
//$document->addStyleDeclaration($css);
Create different language versions of the same article using
the same alias. (IMPORTANT!!)