Page results filter reverts to default when navigating between pages
I've created an image gallery and am using the following filters to sort the results displayed on the page:
Which works great and filters as expected, until I navigate to another page within the pagination (.aspx?page=2) and the filter reverts to the default options. I need it to save the selected options and displayed the filtered results accordingly.
Here's a snippet of the XSLT I'm using, if needed I post the entire XSLT:
The umbraco.library static class has a bunch of helpers for managing session & other variables. As you are navigating using a querystring, the form is not submitted, and your controls inside XSLT do not have viewstate - the ability to retain their values between page submissions.
There are two ways around this:
Re-code your gallery (or your filter section) as an ASP.NET usercontrol, and enable viewstate on the controls;
When changing the form values, manually build a string in Javascript that contains the name and value of each control (or, save the values into a cookie with Javascript). Then, when paginating, either tack the Javascript string on the end of your querystring and retrieve the values usingumbraco.library:RequestQueryString("myparam")in you XSLT, or retrieve the values from the cookies usingumbraco.library.RequestCookies("myparam")to then determine which form options need making as "selected" when rendering your<select>options.
I'm not sure how to do either. But would prefer the second option.
Also my page template has a form wrapping the content.
So I do not want a nested form. But removing the form from my filter XSL code, causes the filter to only work for a few changes. After a couple of changes it no longer filters. What should I do?
The best solution to this, is to switch your form to use GET instead, and make your pagination code use the full QueryString and just replace the "page" parameter when switching pages. That way, it's also possible to bookmark a specific page in a setting.
Page results filter reverts to default when navigating between pages
I've created an image gallery and am using the following filters to sort the results displayed on the page:
Which works great and filters as expected, until I navigate to another page within the pagination (.aspx?page=2) and the filter reverts to the default options. I need it to save the selected options and displayed the filtered results accordingly.
Here's a snippet of the XSLT I'm using, if needed I post the entire XSLT:
If anyone can help it would be greatly appreciated.
Cheers, JV
I was suggested the following:
The umbraco.library static class has a bunch of helpers for managing session & other variables. As you are navigating using a querystring, the form is not submitted, and your controls inside XSLT do not have viewstate - the ability to retain their values between page submissions.
There are two ways around this:
umbraco.library:RequestQueryString("myparam")
in you XSLT, or retrieve the values from the cookies usingumbraco.library.RequestCookies("myparam")
to then determine which form options need making as "selected" when rendering your<select>
options.I'm not sure how to do either. But would prefer the second option.
Also my page template has a form wrapping the content.
So I do not want a nested form. But removing the form from my filter XSL code, causes the filter to only work for a few changes. After a couple of changes it no longer filters. What should I do?
Hi JV,
The best solution to this, is to switch your form to use GET instead, and make your pagination code use the full QueryString and just replace the "page" parameter when switching pages. That way, it's also possible to bookmark a specific page in a setting.
I have a PaginationHelper XSLT file here which you can either use, or have look at for insight on how to achieve this.
/Chriztian
Thanks Chriztian, I'll need help with doing that I think.
I had a look at your PaginationHelper, looks like it could help with this particular issue. But once again I'll need some help with it.
I'm posting my full code here in case anyone can help me out, would be great appreciated:
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.