RS!Form: How to set up a redirect based on the language used in the frontend

How to set up a redirect based on the language used in the frontend

RSForm!Pro does not include, by default, a functionality that would enable users to set up a redirect based on the language that is being used on the website's frontend. However, due to the component's high flexibility, this can be implemented using custom scripting. Assuming that you are using English and German in the frontend, please add the following code:

 

$lang =& JFactory::getLanguage();
$language=$lang->getTag();
if ($language=="en-GB")
header('Location: http://www.english-redirect.com/');
elseif ($language=="de-DE")
header('Location: http://www.german-redirect.com/');
else header('Location: http://www.other-redirect.com/');
exit;

 

in the Components >> RSForm!Pro >> Manage Forms >> edit your form >> Properties >> PHP Scripts >> Script called after form has been processed area.

 

Multiple redirect options

If you wish to redirect to a different page for each language, you will need to use more if-elseif statements, one for each frontend language. Let's say that you are using English, German and French, your script should look like this:


$lang =& JFactory::getLanguage();
$tag=$lang->getTag();
if ($tag=="en-GB") header('Location:http://www.firstlink.com');
elseif ($tag=="de-DE") header('Location:http://www.secondlink.com');
elseif ($tag=="fr-FR") header('Location:http://www.thirdlink.com');
die();

Remember to replace http://www.firstlink.com, http://www.secondlink.com and http://www.thirdlink.com with the actual URL's where you want the user to be redirected to.

posted on 2016-11-08 10:26  sportscar  阅读(245)  评论(0)    收藏  举报

导航