Welcome Guest, Not a member yet? Register   Sign In
Resubmit form when changing language on a results page
#1

[eluser]Andy UK[/eluser]
Hi guys,

I have the MY Language extension installed which enables me to run a multilingual site using the
Code:
echo lang('keyword')
function in my views which reference a couple of translation files that hold the keywords and their various translations.

All is working fine except for when a user decides to change the language in the middle of a search results page. That is to say that a form has been submitted and the results of the db search are on the screen.

Now while i am able to capture the form $_POST values in hidden fields, i can't figure out how to both resubmit the form and also change to the requested language.

The code for changing the language to English is something like this:

Code:
echo anchor($this->lang->switch_uri('en'),'<img src="/resources/british_flag.png" />'

Whereas to resubmit the form i use:

Code:
<a ref='script:document.resubmitForm.submit();'><img src='/resources/british_flag.png' /></a>
(form is name resubmitForm. href has been re-written as 'ref' and javascript rewritten as 'script' to avoid them being stripped from the post)

How can i achieve both a language change and a form resubmission? Any elegant solution would be much appreciated!

Thanks!
#2

[eluser]Andy UK[/eluser]
The only way i could find to achieve this was by changing the language links on that one page to run a javascript code that resubmits the form and directs the user to the other language. If anyone has a better solution i'm interested in hearing it!

Andy.
#3

[eluser]Andy UK[/eluser]
Does no-one have any suggestions as to achieving this?
#4

[eluser]n0xie[/eluser]
Save POST in a session. When someone changes the language, redirect back to the search result page and check if there are POST variables in the session. If so, filter the results based on the POST.




Theme © iAndrew 2016 - Forum software by © MyBB