I am going through a dilema and I would like to ask you for a possible solution to this scenario:
User makes a search through a form.
Parameters are received and a CDbCriteria is built
Results displayed
When user clicks a result, new page viewing the selected record is displayed
My question is:
What is the best option to put a link heading back to results page? -location.back is not good as form is POSTED and I dislike the fact to force user to refresh POSTED values (browser requires to do so).
What is the best way to save criteria? Maybe is because I am tired but I cannot decide for the best solution:
a ) Save last search params in a session cookie and check if user POSTs or returns -checking REFERER.
b ) Save last search params in encoded string and attached it to each result link (encoded string will construct the ‘back to results’ link
I have used the second option. I encode, decode and attach to the Link of the displayed page to go back. If anybody requires help with this, let me know.
Thank you Flavio… did it already but I keep this extension for the future!
The problem was that I had POST and GET variables to deal with. I have seen the code within the extension and is quite good. I may look at its guts with a bit more time in order to change its handling for both param var types.
Despite Even though, i’ve written that extension, i’m not sure anymore wether it’s really that useful.
Frankly speaking, i’ve never used it anywhere myself. The only place where it could be practical might be in some backend application. For frontends i’d use your approach b ), because it follows KISS and always creates URLs that are human readable.
Thank you Mike. Nevertheless, I think your extension is great. I have checked out the code and I think that with some tweaks I can actually do what I did for my code. It just needs to support POST.