Forum

Thread tagged as: Question

Nested Filters using perch_custom_content

Hi there,

Is it possible to achieve 'nested' filters when filtering multiple fields using perch_custom_content?

To extend the example given in the 'filtering by multiple fields' section of the docs
(https://docs.grabaperch.com/docs/content/perch-content-custom/) would something like the below be possible? Ive tried putting something together like this and suspect I may be trying to do something filter is unable to do.

E.g. A query to match Bedrooms >= 3 AND price <= 50000 AND (location = London OR location = york)

perch_content_custom('Properties', array(
    'filter'=>array(
        array(
            'filter'=>'bedrooms',
            'match'=>'gte',
            'value'=>'3'
        ),
        array(
            'filter'=>'price',
            'match'=>'lte',
            'value'=>'50000'
        ),
         array(
            'filter'=>array(
                                array(
                                'filter'=>'location',
                                'match'=>'eq',
                                'value'=>'London'
                                ),
                                array(
                                'filter'=>'location',
                                'match'=>'eq',
                                'value'=>'York'
                                ),
                            ),
                'match'=>'or'           
        ),
        ),
    'match'=>'and'
));
David Lee

David Lee 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Not currently. You can have multiple filters, but not nested ones.

Thanks for the quick response Drew.