Forum

Thread tagged as: Question, Problem

Filtering on numbers

Hi Guys,

I am trying to filter some custom content in Perch based on values. Here is my code

                    perch_content_custom('Sizes', array(
                        'filter'    =>  'size_a',
                        'match'     =>  'between',
                        'value'     =>  4.4, 6.0
                    ));

Here is my template

<perch:before>
<table class="table // table--product">
    <thead>
        <tr>
            <th>Part Number</th>
            <th>a (mm)</th>
            <th>b (mm)</th>
            <th>c (mm)</th>
            <th class="show-small">d (mm)</th>
            <th class="show-small">e (mm)</th>
        </tr>
    </thead>
    <tbody>
</perch:before>
        <tr>
            <td><perch:content id="part_no" type="text" label="Part Number" required="true" title="true" /></td>
            <td><perch:content id="size_a" type="number" step="any" min="0" label="A (mm)" required="false" size="s" /></td>
            <td><perch:content id="size_b" type="number" step="any" min="0" label="B (mm)" required="false" size="s" /></td>
            <td><perch:content id="size_c" type="number" step="any" min="0" label="C (mm)" required="false" size="s" /></td>
            <td class="show-small"><perch:content id="size_d" type="number" step="any" min="0" label="D (mm)" required="false" size="s" /></td>
            <td class="show-small"><perch:content id="size_e" type="number" step="any" min="0" label="E (mm)" required="false" size="s" /></td>
        </tr>
<perch:after>
    </tbody>
</table>
</perch:after>

However, I cannot get any results. If I remove the filters then it shows ok. if I set it to match or then this also works. But I want to filter on a range between various values. This is to break up some tables of data and show them in batches.

Any ideas?

Thanks Terry

Terry Upton

Terry Upton 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

This:

'value'     =>  4.4, 6.0

needs to be:

'value'     =>  '4.4, 6.0'

Thanks Drew. That's got it. Although I was sure I tried this :-/

Just a heads up, I looked at the code on the docs here;
https://docs.grabaperch.com/docs/content/perch-content-custom/

which show the values without ' ' - if these need to be updated?

Thanks.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Numbers are correct not to be quoted. You're setting a range, which is different.