issue
is an entry that has a matrix field named contents
, whose blocks have an entries field named works
, and the related works
channel has an entries field named authorPeople
.
Issue 1's contents
consists of 2 blocks: A 'regular' section and an 'alumni' section. On the cover page, I loop through the blocks. For each block, I get the entries related to their authors, so that I'm outputting entries sorted by author last name, where some authors have more than one entry associated:
{% set contributors = craft.entries({
section: 'contributors',
relatedTo: { sourceElement: block.works, field: "authorPeople" }
}) %}
{% set articles = craft.entries({
section: 'works',
relatedTo: contributors
order: 'lastName'
}) %}
That works fine, because I've got access to block.works
. Any optimization tips are welcome :)
On the individual entry page, I want to getPrev
and getNext
entries spanning both blocks. So if you're at the last entry in the 'regular' section, your next link is the first entry in the 'alumni' section. And if you're on the first entry in the 'alumni' section, your prev link is the last entry in the 'regular' section. The last entry in the last section won't return a next link, so I can code in a link to another page, and the first entry in the first section won't return a previous link, so I can code in a link to the cover page.
Without having to loop through the blocks, how can I get that? Trying to order by issue.contents
doesn't seem to work.
{% set issue = craft.entries.section('issues').slug( craft.request.getSegment(2) ).first() %}
. That's what I'm attempting to use forissue.contents
.