2

Is there a simple way to find entries that do not have a relationship with another channel? I see similar questions here and here, but neither seem to work in this context (or I don't know how to adapt their answers).

I have 3 channels, 'accounts', 'clubs' and 'subscriptions'. Every 'subscription' has a required entries field (limit 1) for 'account' and 'club'. In this case, I'm trying to find 'accounts' that are not associated with a club (i.e. do not have a 'subscription'). Sounds like it should be easy, but not finding an answer.

Looking for something like {% set params = params | merge({ not relatedTo : subscriptions }) %}, which obviously doesn't work. I'm using merge because there may be other criteria as well (such as account status, etc).

Any ideas? Thanks.

1 Answer 1

2

You'll need to approach this in two steps:

  1. Get all the entries that DO have relationships.

  2. Filter those entries out of your ElementCriteriaModel, either by using the "not" syntax on the entries id parameter of the craft.entries variable, or by using the without Twig filter in your loop source.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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