VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: tonis on April 29, 2012, 19:05:07 PM

Title: Login redirect in multilingual site
Post by: tonis on April 29, 2012, 19:05:07 PM
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
Title: Re: Login redirect in multilingual site
Post by: patrik60 on April 29, 2012, 23:46:23 PM
This is a Joomla problem. Check this:

http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=27959
Title: Re: Login redirect in multilingual site
Post by: tonis on April 30, 2012, 12:10:09 PM
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?
Title: Re: Login redirect in multilingual site
Post by: patrik60 on April 30, 2012, 16:15:42 PM
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);
}
}
}
}
Title: Re: Login redirect in multilingual site
Post by: tonis on May 01, 2012, 13:36:19 PM
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.