<p>Most of the time, you can check if an <code>ElementQuery</code> parameter has been set by checking the corresponding property name: it will be <code>null</code> if the parameter hasn't been set, and have the previously set value otherwise.</p>
<p><strong>Examples</strong></p>
<p>This will output <code>6</code>:</p>
<pre><code>  {% set query = craft.entries().relatedTo(6) %}
  {{ dump(query.relatedTo) }}
</code></pre>
<p>This will output <code>null</code>:</p>
<pre><code>  {% set query = craft.entries() %}
  {{ dump(query.relatedTo) }}
</code></pre>

CC BY-SA 4.0
2020-10-05T10:35:24.903Z
2020-10-05T10:35:24.903Z
nstCactus
<p>I am creating plugin that provides helper methods for constructing search forms, filtering entry lists
by various params etc. And for that plugin, I need to be able to tell which methods were alredy used on element query object - because if you use same method twice, only second one will be taken into account.</p>
<p>So, it is possible to check if for example <code>relatedTo</code> was used on specific element query object already?</p>

<elementquery>
Check what methods were used on element query
# Check what methods were used on element query

(Asked by: username_0 on 2020-10-02)

I am creating plugin that provides helper methods for constructing search forms, filtering entry lists
by various params etc. And for that plugin, I need to be able to tell which methods were alredy used on element query object - because if you use same method twice, only second one will be taken into account.

So, it is possible to check if for example `relatedTo` was used on specific element query object already?

**Tags:** elementquery

---

## 1 answers

### Answer by username_1 on 2020-10-05. Score: 2 | Accepted answer

Most of the time, you can check if an ElementQuery parameter has been set by checking the corresponding property name: it will be null if the parameter hasn't been set, and have the previously set value otherwise.
Examples
This will output 6:
  {% set query = craft.entries().relatedTo(6) %}
  {{ dump(query.relatedTo) }}

This will output null:
  {% set query = craft.entries() %}
  {{ dump(query.relatedTo) }}


---

