Skip Navigation

[Resuelto] Never display «no results» with checkbox filters

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

Problem: I would like to create a View that does not allow Users to select filters that will return no results. If I add a checkboxes field to my filters and select "Only show available inputs" in advanced search settings, checkboxes are not updated like other input types. Users are able to select checkboxes that return "No results found"

Solution: Our developers have released a patch for this known issue, and will implement the permanent fix in a future release.

Relevant Documentation: https://toolset.com/errata/checkboxes-are-not-working-like-multi-select-when-only-show-available-inputs-is-selected-in-the-advanced-search-settings/

This support ticket is created hace 7 años, 2 meses. 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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Este tema contiene 17 respuestas, tiene 2 mensajes.

Última actualización por Ido Angel hace 7 años, 1 mes.

Asistido por: Christian Cox.

Autor
Mensajes
#568575

hey,
i asked this before but didn't quite get an answer:

I'm building a recipe site, and search is by custom taxonomy "ingredient". the relationship in the search form is "all values", as i want to show only recipes with all ingredients chosen (in checkboxes).

however, sometimes the user can pick a few ingredients and get no results, and not know which ingredient is "jamming" the search.

so i want to be able to give him ALMOST accurate results. for example show recipes with only 3 ingredients from the 4 he checked, and if possible list somewhere the 1 ingredient which is missing.

at first i was thinking of creating a different search view (category maybe?) and placing it instead of the "no results" text. but that didn't work.

any ideas?

thanks!
Ido

#568621

so i want to be able to give him ALMOST accurate results. for example show recipes with only 3 ingredients from the 4 he checked, and if possible list somewhere the 1 ingredient which is missing.
The "missing" ingredients list would require some more advanced custom code, but the "only show available inputs" advanced custom search option might be a useful alternative. See our document here:
https://toolset.com/documentation/user-guides/front-page-filters/advanced-settings-custom-search/

When you choose this advanced search setting, the search filter options will update any time the user makes a filter selection. Then the only filter options that will be displayed will include results, if added to the current filters. Users will not be able to produce an empty result set like this, but it also means that all filter options will not be displayed all the time - only the combinations that produce results.

at first i was thinking of creating a different search view (category maybe?) and placing it instead of the "no results" text. but that didn't work
I don't see any reason why this wouldn't work, unless this View is set up to respond to the same URL parameters as your original View, causing some conflicts. You would be able to get around this by removing any Filter Controls from this View, and predefining search criteria in your Query Filters. If you'd like to explore this a bit more, I would need to see more details about the two Views and how you have integrated them.

#568629

thank C 🙂

1. choosing "only show available inputs" doesn't work for some reason. maybe because it's checkboxes for a single filter? when i check "cheese", all other checkboxes (fot other ingredients, even if they are not available) stay. if that would work - it would be a great solution.

2) what i tried was create a new view with filter "categories" and based it on the current post in the loop. but i think anyway it wouldn't be a good solution because i need to base the search on ingredients and not categories...
i thought of maybe creating a new view of "ingredients" just instead of "all values" make it "any value" - and place only the search results instead of the initial search's "no results found" text. but that ended with the same result.

#568650

if that would work - it would be a great solution.
I see what you mean. The interesting thing is that if I choose the "multiple select" input type, the available options update as I would expect, but the behavior with checkboxes is not the same. I feel like this may be a bug, but I wanted to offer the multiple select input field as a temporary solution. I can escalate the issue with checkboxes not disappearing to our 2nd tier support team for further investigation. Let me know if you'd like to investigate this further and I will proceed there.

what i tried was create a new view with filter "categories" and based it on the current post in the loop.
I think you would create a new View of recipes, using the same filters as your current View of recipes, but change "All" to "Any" as you described. Then place this View in the other View instead of "No results found".

#568666

hey,

1) yes, please escalate this - i think it would also benefit others. i tried the "multi select" and it indeed works - but:
a) all taxonomies are in one box, which doesn't look great. if it would only look like when adding a category within a post (the categories are added one by one) - it would be better.
b) it's hard to style with css.

2) of course - this is what i tried 🙂 but then, i get ALL recipes when there's "no results" instead of just something close to the ingredients search.

thanks!

#568739

but then, i get ALL recipes when there's "no results" instead of just something close to the ingredients search.
Well not all recipes, only those that match any of the terms selected (which may be quite a few). I'm not clear on what you would like to show here instead, but it sounds like you would like to show the closest matching results. This type of logic isn't easily scripted in Views, so I can't think of a good way to do this without custom code. By design, you can search for matching all terms, any terms, or none of these terms. Beyond that you will need to use our Views filter hooks to modify the WP Query on-the-fly:
https://toolset.com/documentation/programmer-reference/views-filters/

yes, please escalate this - i think it would also benefit others.
Absolutely. I have escalated this and will continue to update you here as I receive more information.

#568791

hey,

1) it's show all recipes because always all inputs are available, i think. but let's forget about it - it doesn't help the issue anyway 🙂

2) thanks! looking forward to hearing about this...

ido

#569541

Ah yes, I see what you mean 🙂 Anyway, our 2nd tier support team has confirmed the issue and escalated it further to our developers. They will continue to investigate and as soon as I hear additional info from them I will update the ticket here. Thanks for your patience while we work on the problem.

#569544

thanks! much appreciated 🙂

#575417

Hi, our developers have released an errata and patch you can find here:
https://toolset.com/errata/checkboxes-are-not-working-like-multi-select-when-only-show-available-inputs-is-selected-in-the-advanced-search-settings/

The next release of the Views plugin will include a permanent fix for this issue, but you can follow the steps in the link above to install a temporary fix if necessary. Let me know if the problem is not resolved and I'll take another look.

#575446

works, thanks!
the only thing is that after checking one checkbox now, it changes the structure of the HTML. if before checking it was:

<label>
<div class="checker">
<span>
<input type="checkbox">

then AFTER checking it's:

<label>
<input type="checkbox">

and the "checker" div and the span are missing. this only happens when i mark "only show available inputs".

thanks!

#575499

Can you share the full contents of your Filter Controls panel for this View? Is any custom JavaScript applied to the filters? Does the behavior change when you activate a default theme like Twenty Seventeen?

#575566

hey,
here it is. no additional JS. strangley, on twentyseventeen, there are no checkboxes AT ALL. simply not appearing in the filter.

[wpv-filter-start hide="false"]
[wpv-filter-controls]
<div class="form-group">
  <label><h1>[wpml-string context="wpv-views"]What's in your fridge?[/wpml-string]</h1></label>
  <h2>Mark the ingredients:</h2>
	[wpv-control-post-taxonomy taxonomy="ingredient" type="checkboxes" url_param="wpv-ingredient"]
  </div>
[/wpv-filter-controls]
[wpv-filter-end]
#575756

Okay I think it's probably best at this point for me to make a clone of your site so I can do some further testing. I can install the Duplicator plugin to create that clone. If that's okay with you, please provide login credentials in the private reply fields here.

Let me know which View you are working on and where I can see the View on the site.

#575866

Thanks I was able to log in and I'm in the process of making a clone now. Which View should I look at, and where can I see the View on the front-end of the site?