0

Pretty much after what the title says.

Is there a way to reset/unset a POST value if it is currently set utilizing a button. The idea here, is the button would be a filter of sorts, so clicking would remove certain portions of the URL if currently set.

As an example: Say we have a button, <a href="#" class="unsetFilter1">Remove filter 1</a> and upon clicking, it would do something along the lines of checking {if '{exp:channel_search:is_set name="filter1"}' == 1} where if TRUE (as the statement is setup), do something like {exp:channel_search:reset name="filter1"}

It seems possible, as all the components needed are there, just not sure how to actually set this up?

0

So I think I've got this figured out. Here's what I did:

{if '{exp:channel_search:is_set name="filter1"}' == 1}
    {!-- If here, the filter is applied, unset it and go back to page one as results will differ --}
    <a href="{exp:channel_search:url set:filter1='' set:page='1'}" class="button secondary disabled">Show locations that match filter1</a>
{if:else}
    {!-- If here, the filter is NOT applied, set it and go back to page one as results will differ --}
    <a href="{exp:channel_search:url set:filter1='SOME_TITLE_TO_FILTER' set:page='1'}" class="button secondary">Hide locations that match filter1</a>
{/if}

Basically, I'm checking if the variable is set, and if so get the current URL, unset the variable, set the page to 1 and go to this URL in click. Do the opposite if not set.

I added a default search rule to accomplish the filtering enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.