Skip Navigation

[Resuelto] Using AND or Or for front-end filters

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

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 19:00 10:00 – 19:00 10:00 – 19:00 10:00 – 19:00 10:00 – 19:00 -
- - - - - - -

Supporter timezone: Europe/Madrid (GMT+01:00)

This topic contains 9 respuestas, has 2 mensajes.

Last updated by Brent hace 9 años, 9 meses.

Assigned support staff: Caridad.

Autor
Mensajes
#34817

Working with a parametric search, was wondering after reading part of another post and testing myself, is there a way to use 'AND' for some custom field queries and 'OR' for others. Read below...

"Because you have OR between your conditions, records that match any of the other conditions will be displayed. Even if the date is outside of the range. Try using AND and you will only get those entries between the dates.
"

Here is my url: hidden link

It seems if I use only 'OR' it doesn't limit the results correctly as stated above, but if I us only 'AND', the user is required to fill in all fields before it returns a result. I would like the user not to have to modify every field if it is not needed for their search. Is their a way to use a combination of both 'AND & 'OR' in a query or some other way to go about this that would be better?

#34870

Dear Brent,

For an interval of dates, you can use the BETWEEN operator for comparing. This operator will ask you to introduce two URL parameters and so two filter controls. This way you can set AND/OR and still have the result dates between the required ones.

Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.

Regards,
Caridad

#35150

Yes I understand that, as you see I have accomplished that.
hidden link

I need to have results returned without the user having to fill in all of the filter inputs when they do a search.
I can do this when using 'Or' but then i run into this issue:
"Because you have OR between your conditions, records that match any of the other conditions will be displayed. Even if the date is outside of the range. Try using AND and you will only get those entries between the dates.
"
Using 'AND' the user is required to have all inputs filled in before it returns a result, not good for me.

So in my case, what i need to have happen is when a user sets a min-date and max-date, it should return all results between those two dates without the user having to select an area or lease type.
If the user does select an area or lease type, the results should then return posts that match the selected area or lease type between the selected dates.

Hope this makes sense.

#35222

Dear Brent,

Can you me a screenshot of the filters while editing your View?

Regards,
Caridad

#35262
Edit-View-Rent-Charleston.jpg

Here is a screen shot of my current filters and view for this.

#35362

Dear Brent,

Changing the custom relationship to OR should works as you say. If it doesn't it means we have found a bug. Can you confirm?

Regards,
Caridad

#35376

HI thanks for the response, I think i figured most of it out. I was using a ' -' with a default value of 0 for the custom filters. These have to be blank so they don't pass any variables to the url string. Maybe you guys should make this more clear in your parametric filtering tuts.

The only thing I can't get to work is the dates because the datepicker automatically chooses today's date as it's default value and therefore passes that to the query string regardless if the user sets a min or max date. So it there a way to define default values for the date pickers?

#35506

Dear Brent,

I dont know of a way to set default values, but let me ask the developers for ideas.

Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.

Regards,
Caridad

#35592

Dear Brent,

We don't have a way of setting the default date for the date control in the front end filters. We will add it to our future todo list for Views.

Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.

Regards,
Caridad

#55862

No sweat, can do without for now.
Here is my final results.
hidden link