2

I have something I can not get my head around.

This works as expected:

.relatedTo(['and',{targetElement:22},{targetElement:33}])

But when I am building an array to use as relation criteria like so:

{% set related = [{targetElement:22},{targetElement:33}] %}

.relatedTo(['and',related])

Nothing returns.

It’s pretty late here in Berlin and I might be missing something simple but can not see what exactly. Anyone?

2

I don’t know what it is – I swear: every time – but the next thing I tried, immediately after posting the question was this:

{% set related = ['and',] %}
{% for relation in relations %}
    {% set related = related|merge([{targetElement:relation}]) %}
{% endfor %}

{% paginate craft.entries
    .section('documents')
    .relatedTo(related)
    as entries %}   

That works.

| improve this answer | |

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.