Forum

Thread tagged as: Question, Configuration, Forum
Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok, that looks fine.

I'm not quite following what the error is, to be honest.

Ok, I'll try and explain the error as simply as possible.

Theres two products I've entered.

  1. Product one is Type 1 (filtered by the first select) and Voltage 2 (filtered by the second select)

  2. Product two is Type 1 (filtered by the first select) and Voltage 1 (filtered by the second select)

When type 1 is selected in the first select and voltage 2 selected in the second select both products are still appearing.

The second filter doesn't seem to filtering the results down further.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Are you using AND or OR?

am using OR at the moment, when using AND I get no results

// Then get the list
perch_content_custom('Products', array(
    'page'=>'/products.php',
    'template'=>'filter-listing.html',
    'sort'  => 'postDateTime', 
    'sort-order' => 'DESC',
    'filter'     => $filters, 
    'match' => 'or'
));

Right, I've cracked the issue...

my second filter id was part of a perch repeater list (as multiple voltages can apply) - I removed the repeater and the filter now filters everything correctly!

Two questions (and I apologise profusely for being an idiot)

  1. Can this not work with a content id inside a repeater (I thought it would) and is there any way around it?

  2. Is there a way of showing a message if non of the filters match (there are a few cases where combinations of types and voltages don't have a product associated).

Many many many thanks for your help, it's been invaluable

Nik

Drew McLellan

Drew McLellan 2638 points
Perch Support

You can't filter based on the contents of a repeater. Well, you can, but you're filtering items, not repeater items. So you can filter items based on something that appears in that item's repeater. Use repeater_id.field_id.

You can use a <perch:noresults> section for displaying a message when there are no results.

Nailed it Drew, all filtering correctly now with both filters.

Adding the repeater.field into my code has opened up all the filtering I needed... last piece of the jigsaw.

Thanks so much for putting up with me and my relentless questions. Think I've tested your tutorial almost to destruction!

Cheers

Drew McLellan

Drew McLellan 2638 points
Perch Support

No problem!