Filter a collection by category

  • I've created a collection in runway to hold products. The products will be shown in various categories and I'm trying to filter the collection on the category but it's not yielding any results:

    1. perch_collection('Hardware', [
    2. 'template'=>'_hardware/hardware_cameo.html',
    3. 'category' => perch_get('category'),
    4. ]);

    The 'category' is obtained from the slug and is working when showing the info for that category, just not for the collection.

    Any ideas how to get this working?

  • Found the issue it has to be the full slug of the category including parent.

    1. <?php
    2. $category = perch_get('category');
    3. perch_collection('Hardware', [
    4. 'template'=>'_hardware/hardware_cameo.html',
    5. 'category'=> 'hardware-categories/'.$category,
    6. ]);
    7. ?>