<p>The way the plugin is currently written, it won't support your initial syntax. i.e. <code>range('and', '&gt;=' ~ result.points, '&lt;=' ~ result.points)</code>.  It would need to override <a href="https://craftcms.com/classreference/fieldtypes/BaseFieldType#modifyElementsQuery-detail" rel="nofollow noreferrer">BaseFieldType's modifyElementsQuery</a> to support that syntax.</p>

<p>You could slightly improve on your solution by using the <a href="https://straightupcraft.com/craft-plugins/mn-break-and-continue" rel="nofollow noreferrer">MN Break and Continue</a> plugin to at least break out of the for loop once a match is found.</p>

CC BY-SA 3.0
2016-08-09T14:07:52.730Z
Hey, thanks for your input and pointers Brad. I'll use your solution as a temporary band-aid. Going to put in a FR with Max to see if he will add the `modifyElementsQuery()` method.
Siebird
CC BY-SA 4.0
2016-08-09T00:05:16.357Z
2019-04-22T22:45:36.203Z
2019-04-22T22:45:36.203Z
Brad Bell
<p>I have a super table field (<code>scoreRanges</code>) that has two columns: <a href="https://github.com/MaxLazar/mx-rangeslider-craftcms" rel="nofollow noreferrer">mx range slider</a> (<code>range</code>) &amp; rich text (<code>summary</code>). Some entries can have multiple rows:</p>

<p><a href="https://i.sstatic.net/q6R9o.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/q6R9o.png" alt="enter image description here"></a></p>

<p>I'm trying search a row in that field that has a range between a certain value. MX range slider saves data ranges to the database text field like <code>9;20</code> which is a range from <code>9</code> to <code>20</code>. </p>

<p>Does anyone have an idea of how to search for a row between a certain range? So far I have tried this which returns no results.</p>

<pre><code>{% for range in profile.scoreRanges.range('and', '&gt;=' ~ result.points, '&lt;=' ~ result.points) %}
...
{% endfor %}
</code></pre>

<p>On the template side, I have variables like <code>{{ range.range.from }}</code> &amp; <code>{{ range.range.to }}</code> to use.</p>

<h1>Update</h1>

<p>Currently not ideal. Using a conditional to filter the correct row, but will work now <code>¯\_(ツ)_/¯</code></p>

<pre><code>{% for range in profile.scoreRanges %}
    {% if result.points &gt;= range.range.from and result.points &lt;= range.range.to %}
        &lt;p&gt;&lt;span class="label label-warning"&gt;Range:&lt;/span&gt; {{ range.range.from }} - {{ range.range.to }}&lt;br&gt; &lt;span class="label label-primary"&gt;Your Score:&lt;/span&gt; &lt;b&gt;{{ result.points }}&lt;/b&gt;&lt;/p&gt;
        {{ range.summary }}
    {% endif %}
{% endfor %}
</code></pre>

<search><range>
Search using the MX Range Slider plugin
# Search using the MX Range Slider plugin

(Asked by: username_0 on 2016-08-08)

I have a super table field (scoreRanges) that has two columns: mx range slider (range) & rich text (summary). Some entries can have multiple rows:

I'm trying search a row in that field that has a range between a certain value. MX range slider saves data ranges to the database text field like 9;20 which is a range from 9 to 20. 
Does anyone have an idea of how to search for a row between a certain range? So far I have tried this which returns no results.
{% for range in profile.scoreRanges.range('and', '>=' ~ result.points, '<=' ~ result.points) %}
...
{% endfor %}

On the template side, I have variables like {{ range.range.from }} & {{ range.range.to }} to use.
Update
Currently not ideal. Using a conditional to filter the correct row, but will work now ¯\_(ツ)_/¯
{% for range in profile.scoreRanges %}
    {% if result.points >= range.range.from and result.points <= range.range.to %}
        Range: {{ range.range.from }} - {{ range.range.to }} Your Score: {{ result.points }}
        {{ range.summary }}
    {% endif %}
{% endfor %}

**Tags:** search, range


---

## 1 answers

### Answer by username_1 on 2016-08-09. Score: 3 | Accepted answer

The way the plugin is currently written, it won't support your initial syntax. i.e. `range('and', '>=' ~ result.points, '<=' ~ result.points)`. It would need to override [BaseFieldType's modifyElementsQuery](https://craftcms.com/classreference/fieldtypes/BaseFieldType#modifyElementsQuery-detail) to support that syntax.

You could slightly improve on your solution by using the [MN Break and Continue](https://straightupcraft.com/craft-plugins/mn-break-and-continue) plugin to at least break out of the for loop once a match is found.

> **Comments:**
> **username_0**: Hey, thanks for your input and pointers Brad. I'll use your solution as a temporary band-aid. Going to put in a FR with Max to see if he will add the `modifyElementsQuery()` method.  

---

