News:

Support the VirtueMart project and become a member

Main Menu

Login redirect in multilingual site

Started by tonis, April 29, 2012, 19:05:07 PM

Previous topic - Next topic

tonis

Hello

Im building a multilingual eshop and I have a little problem with login. When i login from another language as the default, Im redirected to the homepage of the default language.

How can a change the redirect, to stay on the chosen language and not to go to the homepage.

Joomla 2.5.4
VM 2.0.6


tonis

#2
Thanks

But in the Joomla version i use, this patch is already implemented, and the problem still remains. And the problem is there in both cases - with SEF and also without SEF.

When i manually set language in user profile, then after login he remains on the choosen language. Is there a way how to set the site language automaticaly after registration, depending on from which language he has registered?

patrik60

No, it's still not working.

Try to delete the following lines in plugins/system/languagefilter/languagefilter.php:

public function onUserLogin($user, $options = array())
{
$app = JFactory::getApplication();
$menu = $app->getMenu();
if ($app->isSite() && $this->params->get('automatic_change', 1))
{
// Load associations
if ($app->get('menu_associations', 0)) {
$active = $menu->getActive();
if ($active) {
$associations = MenusHelper::getAssociations($active->id);
}
}

$lang_code = $user['language'];
if (empty($lang_code))
{
$lang_code = self::$default_lang;
}
if ($lang_code != self::$tag)
{
// Change language
self::$tag = $lang_code;

// Create a cookie
$conf = JFactory::getConfig();
$cookie_domain = $conf->get('config.cookie_domain', '');
$cookie_path = $conf->get('config.cookie_path', '/');
setcookie(JApplication::getHash('language'), $lang_code, time() + 365 * 86400, $cookie_path, $cookie_domain);

// Change the language code
JFactory::getLanguage()->setLanguage($lang_code);

// Change the redirect (language have changed)
if (isset($associations[$lang_code]) && $menu->getItem($associations[$lang_code])) {
$itemid = $associations[$lang_code];
$app->setUserState('users.login.form.return', 'index.php?&Itemid='.$itemid);
}
else
{
$itemid = isset($homes[$lang_code]) ? $homes[$lang_code]->id : $homes['*']->id;
$app->setUserState('users.login.form.return', 'index.php?&Itemid='.$itemid);
}
}
}
}

tonis

Thanks, this seems to help.

I have done a little testing and everything works. Now after login in other language as default, user is no longer redirected to default language.


For those who will implement this. When you now enable to users to set language in their profiles, thei will not be redirected to the language after login.