Forums

Redirect problem in a multilingual site

jordisola 18 Apr, 2011
I'm using a form (http://www.clauconsultors.com/en/contact/request-information.html) made with Chronoforms in a multilingual site that works with JoomFish and sh404sef. My problem is that redirection after sending the mail always leads to the page in the site default language instead of sending to the language the visitor is using.

I put the url in the field 'Redirect URL' of the form, I put this code
<?php
   $myForm->formrow->redirecturl .= '&lang='.JRequest::getVar('lang','en');
?>

in 'On submit after email' field and I translate all text in the form using Joom!Fish content element for ChronoForms.

I wrote on this forum a year ago about this topic and you said me to review this http://www.chronoengine.com/forums.html?cont=posts&f=2&t=15175&p=36953#p36953). As you can see, it does'nt work for me. Like I could not make it work I forget this topic until now.
GreyHead 19 Apr, 2011
Hi jordisola,

I think it might work if you get the language from the Joomla! language object
<?php
$lang = & JFactory::getLanguage();
$myForm->formrow->redirecturl .= '&lang='.$lang->getTag();
?>


Bob

PS This will give e.g. lang=en-GB; I guess that you might need to trim it down to lang=en ???
GreyHead 20 Apr, 2011
Hi jordisola,

Please try changing the code to
$myForm->formrow->redirecturl .= '&lang='.$lang->getTag();

Bob
jordisola 21 Apr, 2011
Hi Bob,

Your suggested code adds the complete iso code for the default language. Default language yet.

I tried a different version of code to take only the two first characters
<?php
$lang = explode('-',JFactory::getLanguage()->_lang);
$MyForm->formrow->redirecturl .= '&lang='.$lang[0];
?>


and now I can add to redirect URL '&lang=en' for example.

But main problem still remains than I get default language of site instead current language.

Jordi,
GreyHead 22 Apr, 2011
Hi Jordi,

It's actually getting you the current language (or should do). $lang->getDefault() gets you the default language.

Perhaps something isn't setting the current language correctly?

Bob
jordisola 26 Apr, 2011
Hi,

Perhaps something isn't setting the current language correctly?



Maybe but I cannot see any malfunction more using the different languages.

How can I check if there is any problem setting the current language?

Jordi,
GreyHead 26 Apr, 2011
Hi Jordi,

Well . . . add this to a test form (or a module using something like Jumi)
<?php
$lang = JFactory::getLanguage();
echo "<div>The current language is: {$lang->_lang}</div>";
?>

Bob
jordisola 26 Apr, 2011
Hi,

There isn't any problem setting current language.

I put your piece of code within the form page and the confirmation page and then (in a local copy) I'he disabled sh404sef and SEF. What happens is:
1/ I go to the form page (http://localhost/joomla15/index.php?option=com_content&view=article&id=87&catid=17&Itemid=85&lang=en). Inside appairs 'The current language is: en-GB'.
2/ Redirect URL is http://localhost/joomla15/index.php?option=com_content&view=article&catid=17&id=90 and in On Submit Code there is
<?php
$lang = JFactory::getLanguage();
$MyForm->formrow->redirecturl .= '&lang='.$lang->getTag();
?>

3/ I fill the form and submit
4/ I'm redirected to http://localhost/joomla15/index.php?option=com_content&view=article&catid=17&id=90&lang=es-ES. Inside appairs 'The current language is: es-ES'.

Any idea?

Jordi,
This topic is locked and no more replies can be posted.