<p>If found the answer. You can use an * operator in the search query to check if a category field is not empty. So the solution in my case was:</p>

<pre><code>'search' =&gt; lightswitchOne:1 OR lightswitchTwo:1 OR lightswitchThree:1 OR categoryOne:* OR categoryTwo:*
</code></pre>

CC BY-SA 4.0
2018-08-21T07:36:23.413Z
2018-08-21T07:36:23.413Z
Joris
<p>Basically I’m trying to get en Entry where, either one (or more) of three lightswitches is (are) turned on, or where either categoryOne or categoryTwo is not empty.</p>

<p>This is what I got so far, but it doesn't seem to work.</p>

<pre><code>$criteria = [
    'section' =&gt; 'news',
    'limit' =&gt; 100,
    'search' =&gt; ‘lightswitchOne:1 OR lightswitchTwo:1 OR lightswitchThree:1’,
    'categoryOne' =&gt; ':notempty:’,
    'categoryTwo’ =&gt; ':notempty:’,
    'id' =&gt; 'and, not 1, not 2’//Also exclude a couple id's
];
$criteriaModel = craft()-&gt;elements-&gt;getCriteria("Entry");
$criteriaModel-&gt;setAttributes($criteria);
return $criteriaModel-&gt;find();
</code></pre>

<p>Is there a way to do this is in Craft?</p>

CC BY-SA 4.0
2018-08-16T22:28:23.897Z
would you mind adding what worked for you as an official answer in case it helps someone in the future?
Brad Bell
<plugin-development><elementcriteriamodel>
Plugin, getting an entry when one of multiple category fields and/or lightswitches are not empty/turned on
# Plugin, getting an entry when one of multiple category fields and/or lightswitches are not empty/turned on

(Asked by: username_0 on 2018-08-16)

Basically I’m trying to get en Entry where, either one (or more) of three lightswitches is (are) turned on, or where either categoryOne or categoryTwo is not empty.
This is what I got so far, but it doesn't seem to work.
$criteria = [
    'section' => 'news',
    'limit' => 100,
    'search' => ‘lightswitchOne:1 OR lightswitchTwo:1 OR lightswitchThree:1’,
    'categoryOne' => ':notempty:’,
    'categoryTwo’ => ':notempty:’,
    'id' => 'and, not 1, not 2’//Also exclude a couple id's
];
$criteriaModel = craft()->elements->getCriteria("Entry");
$criteriaModel->setAttributes($criteria);
return $criteriaModel->find();

Is there a way to do this is in Craft?

**Tags:** plugin-development, elementcriteriamodel
> **Comments:**
> **username_1**: would you mind adding what worked for you as an official answer in case it helps someone in the future?  

---

## 1 answers

### Answer by username_0 on 2018-08-21. Score: 0 | Accepted answer

If found the answer. You can use an * operator in the search query to check if a category field is not empty. So the solution in my case was:
'search' => lightswitchOne:1 OR lightswitchTwo:1 OR lightswitchThree:1 OR categoryOne:* OR categoryTwo:*


---

