I want to do exactly this: Multi-step & bi-directional relations with relatedTo (#1640)
Common example: Let’s say you have Books, Authors, and Publishers, and two relationship fields on the Books channel:
authorandpublisher. On a Publisher’s page, you want to list all of the Authors that have published books with them.
Here’s what I’ve tried:
{% set bookIds = craft.entries()
.section('books')
.relatedTo({ targetElement: publisher, field: 'publisher' })
.ids() %}
{% set authors = craft.entries()
.section('authors')
.relatedTo({ sourceElement: bookIds, field: 'books' })
.all() %}
However the code results in an "Undefined offset: 0" error. The error seems to occur in the first block of code.
Additionally, I'm not sure about the field in the penultimate line, shouldn't it be 'authors' rather than 'books'?
craft/storage/runtime/logs/craft.log, etc.) for the error message you’re getting. Can you post the stack trace that gets logged with it? – Brandon Kelly Oct 17 '17 at 10:42field: 'books'should have beenfield: 'author'. Just updated the GH issue. – Brandon Kelly Oct 17 '17 at 10:46http://textuploader.com/d4uuk
– Rivu Meyano Oct 17 '17 at 12:30