Skip Navigation

[Closed] Create link badge to remove filters

This support ticket is created 4 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 5 replies, has 3 voices.

Last updated by Shane 4 years, 2 months ago.

Assisted by: Shane.

Author
Posts
#1742115

Yes it works, can you help to create a link badge to remove filters, or i need to create another ticket?

#1742151

Could you provide some more details about this? Where would you like to show this link? What filters would you like to remove when the link is clicked?

#1742945
Schermata 2020-08-18 alle 10.43.53.png
Schermata 2020-08-18 alle 10.41.04.png

Ok I would create a "remove filter" badge for each active filter.

1. Filter Removing

Like on this page:
hidden link
after the "La tua ricerca" there is a list of all active filters:
Ricevimento: is the custom post type selection
Ville Matrimoni: is the 1° Taxonomy (type of location)
Lazio & Roma: is the 2° Taxonomy (in our case Citta)
Genzano di Roma: is another taxonomy (we don't have, it is the district, and it depends of the città)

In our case:
Starting from a url like this:
hidden link

Where:
eventi-aziendali is the 1° taxonomy
and
roma-centro is the 2° Taxonomy

The remove filters link should be like so:

a.
Remove 1° Taxonomy

[Roma Centro x ]
Linking to
hidden link

b.
Remove 2° Taxonomy

[Eventi Aziendali x]
Linking to
hidden link
(it could be better transform it to hidden link but it doesn't work)

2. Custom Search in Taxonomy page and filter

I'd like my Search to include also additional filters.
I'll try to explain better:

In the taxonomy view the search filters should be the same taxonomy but the user could search also for custom fields in the taxonomy view
i'll post images

3. It could be great to integrare the District like in question 1, but i don't think it is possibile

#1743483

Okay I see what you mean now, thank you for the additional information. Toolset offers one shortcode wpv-filter-reset that can be used to create a link or button to reset all of a View's filters at the same time: https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#vf-214912
However, there is nothing built-in to Views that will display a list of active filters, and there is no built-in way to remove filters individually. This type of interface will require a significant amount of advanced, custom JavaScript code. Unfortunately there is no JavaScript API available for custom search View filters, so the best way to interact with the filters is to trigger page reloads with modified URL parameters.

So starting from here:
hidden link

You would need a way to access those two URL parameters in JavaScript. You could use a script like this:
https://css-tricks.com/snippets/javascript/get-url-variables/

You would need a way to split the URL by "/" to create an array of paths. You can use JavaScript's "split" method to split the string up into components:
https://www.w3schools.com/jsref/jsref_split.asp

Loop over those parameters and URL directories to create badge links. The link for filter1 should remove the filter1 URL parameter and value:
hidden link
You would have to use JavaScript's String and Array manipulation methods to modify the URL for each link. The links should trigger a full page reload at the new URL. After the page reloads, the filter list should be regenerated.

I can offer guidance for implementing any of the JavaScript event hooks we offer for search, filter update, and pagination events if you need assistance with those:
https://toolset.com/documentation/programmer-reference/adding-custom-javascript-code-to-views-that-use-ajax/
...however the majority of the work here is fairly advanced custom JavaScript.

#1746125

Sure, i would apply this to toolset.
Actually i rewrote the urls of the orginal wordpress taxonomy because it doesn't work on toolset parameters.
It could be simplyest with toolset but i don't know why it does not work

#1757123

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Alessandro,

Christian is currently on vacation at the moment, however based on what i've read you're trying to implement a fairly complex javascript to reset your filter parameters when a button is click.

I'm not 100% clear on the issue to continue assisting so if you can walk me through so that I can understand perhaps I can pickup where Christian left off.

Thanks,
Shane

The topic ‘[Closed] Create link badge to remove filters’ is closed to new replies.