Thread tagged as: Question, Problem

Filtering multiple titles from a collection


I am using Perch Runway and would like to display 6 items from this collection. I am trying to filter by title, but I can't get it to work.

I have tried this:

    perch_collection('Standpunt Pagina', [
        'template' => 'standpunten/standpunt_carousel.html',
        'filter' => 'titel',
        'match' => 'in',
        'value' => 'Immigratie', 'Veiligheid', 'Huisvesting en wonen', 'Jongeren', 'Openbaar vervoer', 'Westlandse cultuur'

Am I separating the values wrong, or using the wrong match?


Mike Hendriks

Mike Hendriks 0 points

  • 3 years ago
Duncan Revell

Duncan Revell 78 points
Registered Developer


'value' => 'Immigratie, Veiligheid, Huisvesting en wonen, Jongeren, Openbaar vervoer, Westlandse cultuur'

That is also not working. I also tried array(['Immigratie', 'Veiligheid', 'Huisvesting en wonen', 'Jongeren', 'Openbaar vervoer', 'Westlandse cultuur']) which is also not working.

Duncan Revell

Duncan Revell 78 points
Registered Developer

The value needs to be a comma-separated string.

Have you tried looking at the debug to see what the database query looks like? Does it work if you filter for just one title?

Debug says the following:

SELECT collectionID, collectionTemplate FROM perch3_collections WHERE collectionKey='Standpunt Pagina'
[1] SELECT * FROM ( SELECT idx.itemID, ci.collectionID, ci.itemJSON, idx2.indexValue as sortval FROM perch3_collection_index idx JOIN perch3_collection_items ci ON idx.itemID=ci.itemID AND idx.itemRev=ci.itemRev AND idx.collectionID=ci.collectionID JOIN perch3_collection_revisions cr ON idx.itemID=cr.itemID AND idx.itemRev=cr.itemRev AND idx.collectionID=ci.collectionID JOIN perch3_collection_index idx2 ON idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev AND idx2.indexKey='_order' WHERE (idx.collectionID=2) AND ((idx.indexKey='titel' AND idx.indexValue IN ('Immigratie', ' Veiligheid', ' Huisvesting en wonen', ' Jongeren', ' Openbaar vervoer', ' Westlandse cultuur'))) AND idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev ) as tbl GROUP BY itemID, itemJSON, sortval ORDER BY sortval ASC LIMIT 0, 6
[1] Using template: /templates/content/standpunten/standpunt_carousel.html
Missing variant.

It does work with only one title.

Duncan Revell

Duncan Revell 78 points
Registered Developer

That query looks as if it's returning one item - is it 'Immigratie'?

If so the string you need is probably:

'value' => 'Immigratie,Veiligheid,Huisvesting en wonen,Jongeren,Openbaar vervoer,Westlandse cultuur'

(removing the leading spaces from each item in the list).

Yes, it is working! Thank you very much Duncan