Forum

Thread tagged as: Question, Problem

Filter by Category?

I've searched in the docs, read what I found, and watched the video on the subject. Portfolio with Categories

However, I'm still not getting my desired result nor understanding the result I do get.

I'm trying something similar to the video. In a jewelry store's website I'm trying to filter rings by categories. in the ring.html template I have:

<perch:categories id="catCollection" set="collection" label="Collection" display-as="checkboxes"></perch:categories>
<perch:categories id="catStyle" set="style" label="Style" display-as="checkboxes"></perch:categories>
<perch:categories id="catType" set="type" label="Type" display-as="checkboxes"></perch:categories>

<!-- these display the separate category sets as check boxes -->

For the Ring page function I have:

perch_content_custom('Rings', array(
     'category'   => perch_get('collection'),
    'template' => 'rings.html',
    'count' => 24,
    'paginate' => true,
));

When 'colection' is not set, I get all of the rings. This is fine. When it is set I get nothing.

I used skip-template and var_dump() to the page:

["catCollection"]=>
    array(1) {
      [0]=>
      string(1) "1"
    }
    ["catStyle"]=>
    array(1) {
      [0]=>
      string(1) "3"
    }
    ["catType"]=>
    array(1) {
      [0]=>
      string(1) "6"
    }

This is the only reference to the categories I find, numbers not values. The values of the categories should be something like "men" "wedding" and such. I assume this is why I can't retrieve the rings I want?? What am I doing wrong/not right?

Nicholas Nelson

Nicholas Nelson 0 points

  • 7 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Are you using a category path, e.g. collection/wedding ?

I'm sorry, I don't understand. Something like this?:

perch_content_custom('Rings', array(
     'category'   => 'collection/' . perch_get('collection'),
    'template' => 'rings.html',
    'count' => 24,
    'paginate' => true,
));
Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, if collection is your set slug.

Awesome, that's the ticket! Thank you