Forum

Thread tagged as: Question

Perch collection multi filtering

Hi,

I'm trying to filter a collection based on three criterias: agenda_importance, end_date and is_pinned. Essentially, if agenda_importance and en_date are set OR if is_pinned is set, the content should be displayed.

perch_collection('Agenda', array(
      'template' => 'agenda/agenda_push.html',
      'sort' => 'start_date',
      'sort-order' => 'DESC',
      'filter' => array(
            array(
                  'filter' => 'agenda_importance',
                  'match' => 'eq',
                  'value' => 'yes',
            ),
            array(
                  'filter' => 'end_date',
                  'match'=>'gt',
                  'value'   => date("Y-m-d"),
            ),
            array(
                  'filter' => 'is_pinned',
                  'match' => 'eq',
                  'value' => 'yes'
            )
      )
));

I understand from the the docs that a filter having two array is by default AND and it can be set to OR. Could it be both?

Thanks!

Robin Pick

Robin Pick 5 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

It can't be both AND and OR. It's one or the other.