Forums

Redirect: Keep lang var?

ronze 13 Jul, 2009
Hey everyone

I've searched the forums for a while but there's no simple explanation on how to do this.

I've created a thank you page an translated it with Joomfish. When I press the form submit button, then the language is removed. If I have chosen a spanish language, then when I press the form, the language will go back to default.

I saw somewhere that you can set the redirecturl in php code, but how can I do this? Then I could just use this:


<?php 
    $lang = &JFactory::getLanguage();
    $redirecturl = "someredirecturl.php?lang=".$lang->get('name');
?> 


Anyone?
GreyHead 13 Jul, 2009
Hi ronze,

The easy way os to use that code on the Thank you page with a switch
switch ($lang) {
case 'Spanish':
default:
  echo 'Thank you in Spanish';
  break;
case 'English':
  echo 'Thank you in English';
  break
}

Bob
ronze 13 Jul, 2009
Yes, but that kind of breaks the idea of managing all translations with Joomfish. Because if it's not a simple thank you page, but a rather advanced one, Joomfish will to the job prettier.

My solution was to enter this code in the onSubmit field:


<?php
   $myForm->formrow->redirecturl .= '&lang='.JRequest::getVar('lang','en');
?>


It appends the current language to the redirect url.
GreyHead 13 Jul, 2009
Hi ronze,

That looks good, thank you.

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