<p>I finally found something that worked after trying various methods:</p>
<pre><code>{% set allEntries = query.all() %}

    {% set allResults = allEntries|filter(entry =&gt;
        entry.associatedBusiness == queryParam or
        entry.businessVertical2 == queryParam or
        entry.businessVertical3 == queryParam
    ) %}

    {% set currentPage = craft.app.request.pageNum %}
    {% set total = allResults|length %}

    {% set offset = (currentPage - 1) * pageSize %}
    {% set pageEntries = allResults|slice(offset, pageSize) %}

    {% set pageInfo = {
        first: 1,
        last: ceil(total / pageSize),
        total: total,
        currentPage: currentPage,
        limit: pageSize,
        offset: offset
    } %}
</code></pre>
<p>and if you want to add paging you can do</p>
<pre><code>{% if pageInfo.total &gt; pageSize %}
                    &lt;div class=&quot;paginationHolder&quot;&gt;
                        &lt;ul class=&quot;pagination&quot;&gt;
                            {% if currentPage &gt; 1 %}
                                &lt;li&gt;&lt;a href=&quot;{{ url(craft.app.request.pathInfo, {page: currentPage-1}) }}&quot;&gt;Previous&lt;/a&gt;&lt;/li&gt;
                            {% endif %}
                            
                            {% if currentPage &lt; pageInfo.last %}
                                &lt;li&gt;&lt;a href=&quot;{{ url(craft.app.request.pathInfo, {page: currentPage+1}) }}&quot;&gt;Next&lt;/a&gt;&lt;/li&gt;
                            {% endif %}
                        &lt;/ul&gt;
                    &lt;/div&gt;
                {% endif %}
</code></pre>

CC BY-SA 4.0
2024-11-14T11:58:00.777Z
Not sure I'd recommend this approach - better to get the stuff you need up front rather than fetching everything and then filtering it. Have you checked Yii's documentation on `where`? https://www.yiiframework.com/doc/api/2.0/yii-db-querytrait#where()-detail - You can add this in a Craft element query something like this: `craft.entries.where(['or', 'fieldColumnName1 = "something"', 'fieldColumnName2 = "another"']).all()`
James Smith
CC BY-SA 4.0
2024-11-14T01:11:31.513Z
2024-11-14T01:13:07.000Z
2024-11-14T01:13:07.000Z
Hector Ochoa
<p>I'm currently querying entries successfully like so for the <code>associatedBusiness</code>
field:</p>
<p><code>{% set query = query.businessVertical(queryParam) %}</code></p>
<p>However I have two other dropdown fields that I would like to check against:</p>
<p><a href="https://i.sstatic.net/c9R8mGgY.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/c9R8mGgY.png" alt="enter image description here" /></a></p>
<p>I tries this but doesn't seem to work:</p>
<p><code>{% set query = query.search('businessVertical:' ~ queryParam ~ ' OR  businessVertical2:' ~ queryParam ~ ' OR  businessVertical3:' ~ queryParam) %}</code></p>
<p>Not sure of any other ways to write this syntax with Craft3</p>

<craft3><query>
Query entries for multiple dropdown field values
# Query entries for multiple dropdown field values

(Asked by: username_0 on 2024-11-13)

I'm currently querying entries successfully like so for the `associatedBusiness`
field:

`{% set query = query.businessVertical(queryParam) %}`

However I have two other dropdown fields that I would like to check against:

[![enter image description here](https://i.sstatic.net/c9R8mGgY.png)](https://i.sstatic.net/c9R8mGgY.png)

I tries this but doesn't seem to work:

`{% set query = query.search('businessVertical:' ~ queryParam ~ ' OR businessVertical2:' ~ queryParam ~ ' OR businessVertical3:' ~ queryParam) %}`

Not sure of any other ways to write this syntax with Craft3

**Tags:** craft3, query


---

## 1 answers

### Answer by username_0 on 2024-11-14. Score: 0

I finally found something that worked after trying various methods:
{% set allEntries = query.all() %}

    {% set allResults = allEntries|filter(entry =>
        entry.associatedBusiness == queryParam or
        entry.businessVertical2 == queryParam or
        entry.businessVertical3 == queryParam
    ) %}

    {% set currentPage = craft.app.request.pageNum %}
    {% set total = allResults|length %}

    {% set offset = (currentPage - 1) * pageSize %}
    {% set pageEntries = allResults|slice(offset, pageSize) %}

    {% set pageInfo = {
        first: 1,
        last: ceil(total / pageSize),
        total: total,
        currentPage: currentPage,
        limit: pageSize,
        offset: offset
    } %}

and if you want to add paging you can do
{% if pageInfo.total > pageSize %}
                    
                        
                            {% if currentPage > 1 %}
                                Previous
                            {% endif %}
                            
                            {% if currentPage < pageInfo.last %}
                                Next
                            {% endif %}
                        
                    
                {% endif %}

> **Comments:**
> **username_1**: Not sure I'd recommend this approach - better to get the stuff you need up front rather than fetching everything and then filtering it. Have you checked Yii's documentation on `where`? https://www.yiiframework.com/doc/api/2.0/yii-db-querytrait#where()-detail - You can add this in a Craft element query something like this: `craft.entries.where(['or', 'fieldColumnName1 = "something"', 'fieldColumnName2 = "another"']).all()`  

---

