Forum

Thread tagged as: Question, Suggestions

Perch Advanced Filtering

Hey,

I need to do some advanced collection filtering within the Collection API. Something like the following expression:

(var=1 OR var2=2) AND var3=3

I'm 95% sure at the moment this isn't possible, right? I've needed it quite a few times, and I'd love this to be added. It's something I've spoken to a few developers about, and there's been a few forum mentions too.

Are my suspicions correct here, it's not possible currently? If not, is it something that could be added in the near future?

Cheers, Ryan.

Ryan Gittings

Ryan Gittings 1 points

  • 2 years ago
Hussein Al Hammad

Hussein Al Hammad 105 points
Registered Developer

Ah I can see this being quite handy.

Not sure what your use case is, but the use case I often come across is when filtering for similar items since you also need to exclude the base item too.

On a real estate website for instance, on a property detail page you may want to display similar properties that are:

  1. Not the same main property on the page
  2. AND in the same location
  3. AND meets at least one other criterion (let's say number of bedrooms OR price range)

So if I were to use a similar expression to yours, it would be

(bedrooms=1 OR price_range=2) AND location=3 AND slug!=perch_get('s')
Ryan Gittings

Ryan Gittings 1 points
Registered Developer

That's exactly my use case too, Hussein.