Forum

Thread tagged as: Suggestions, Runway

Multi-Multi-Filter for collections page functions

In perch_content_custom and perch_collection, you can choose the operand for filters in the page function: 'match'=>'or'.

It would be a nice touch to runway if you could combine filters with OR and AND in the same "query". Something like this:

'filter'=>array(
    'filter'=>array(
      array(
        'filter'=>'some',
        'match'=>'eq',
        'value'=>1,
      ),
     array(
        'filter'=>'other',
        'match'=>'neq',
        'value'=>'',
      ),
      'match'=>'or',
    ),
   'filter'=>array(
      // either it's an original
      array(
        'filter'=>'more',
        'match'=>'eq',
        'value'=>'lorem',
      ),
      array(
        'filter'=>'evenMore',
        'match'=>'eq',
        'value'=>'ipsum',
      ),
      'match'=>'and',
    ),
    'match'=>'or',
),

=> WHERE ('some' eq 1 OR 'other' neq '') OR ('more' eq 'lorem' AND 'evenMore' eq 'ipsum')

Related to https://forum.grabaperch.com/forum/04-13-2016-categories-with-perch-template where I've described a workaround for nearly that problem (main match being AND though)

Urs Bräm

Urs Bräm 1 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You can only pick one filter mode currently. What you've suggested there wouldn't work with PHP as you can't set the same property in a PHP array twice.

ah, true. And nesting it more would make it very hard to use.