1

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?

2

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) }}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.