Filtering with further navigation (next, prev)

Hello Everyone!

I have a couple of websites that have some sort of javascript filtering (checkboxes,radio, etc) and that works well, however want to implement navigation (next and previous) on clicked element but based on the selected filters previously.

I have selected the sector filer that is “Industrial” and the year filter that is “2020” and now when I click on any of these items listed in the grid i am taken to a new page (the browser will refresh) and want to be able to navigate on “sibling resources” through next and prev but based on sector and year filter clicked step before.

I guess will need store these filters somewhere like cookies or something but in my case i cant use cookies :frowning: . Does anybody know good alternative or had similar issue?

thanks in advance!!

Maybe you could use the session variable $_SESSION or add the filters as request parameters to the next/prev links.

Tagger does this out of the box with the getResources WHERE property. Can you use Tagger for filtering?

If not maybe looking at how Tagger utilizes getResources properties might suggest a solution.

Thank you for your response.
Also forgot to mention that i cant add extra parameters to URL (trying to keep links nice a tidy for SEO)
Could you please say a bit more about $_SESSION option?

Thank you for your response.
Ohh i have never though about it! do you have an example implementation somewhere?

Does this mean you use no cookies at all? Or do you still use the normal session cookie (which is set by default in MODX).

If sessions are enabled, then you can use the superglobal variable $_SESSION to store values between different requests from the same user.

Yeah we dont want to use cookie because we will need to put it in the policies, banners etc. to much hassle so best to avoid it.

$_SESSION - that would work, I’m just not sure how exactly because i after clicking on filters checkboxes then i click on the element in tag and that takes me to next page where i expecting to have navigation (next, prev) with the links to elements that were previously filtered.

If you don’t have any cookies (even the session cookie), then there is no way on the server to determine, if the user that requests a page already made a previous request.

You can’t use $_SESSION and you have to provide all necessary information as request parameters (so that the server knows what to do).

Maybe you could instead use AJAX-requests to load/show the clicked item.
(But you probably still need to add parameters for the filters to the AJAX-request.)

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.