Forum

Thread tagged as: Question, Suggestions

Category Filter exact match.

I have several collections that I'm filtering by categories. I'm cycling through all of the categories, and need to have only collection items that exactly match the category I'm at for that part of the cycle.

Say I have the following categories in the "sterlingcategories" set: 1) sterlingcategories/material-handling/ 2) sterlingcategories/material-handling/blending/ 3) sterlingcategories/material-handling/conveying/

When the cycle is in the first category, I don't want to include anything with blending. I want an exact match on the categories. I've tried traditional category filtering, but it will include all collection items for that category and any subcategories. So for #1, it would return all of #2 & #3 where I only want #1.

I also tried a filter on the category (like below), but I'm not sure if it will work that way, or if my syntax is incorrect. (productCategory is my id for the categories in the template)

perch_collection(['Sterling-Products-TC','Sterling-Products-PC','Sterling-Products-MH','Sterling-Products-SR'], [ 'template' =>'product-sterling-productNameOnly.html', 'filter' => 'productCategory', 'match' => 'eq', 'value' => 'sterlingcategories/material-handling/', 'count' =>30 ]);

hope this makes sense.

Raymond Wiggins

Raymond Wiggins 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Categories are hierarchical, so anything in sterlingcategories/material-handling/blending/ is also in sterlingcategories/material-handling/ by definition.

I could conceivably add a mode to ignore the hierarchy, but that doesn't exist at the moment.