I am having the following sections:

1. work (section type: single)
    - workList (type: entries from section type workArticles)

2. workArticles (section type: channel)
    - workName (type: plain text)

So the first section (work) is an overview page that links to pages of the second section (workArticles). Basically a normal portfolio page.

On my workArticles pages I want to link to the next entry from work.workList. So imagine: my portfolio overview page shows 8 projects, the user clicks on the third entry, the page for the third entry opens, on the bottom of that page I want to link to the fourth entry of the list.

Is that even possible?

  • Is there an actual Matrix field involved here (from your question title)? craftcms.com/docs/matrix-fields – Brad Bell Dec 28 '16 at 18:39
  • @BradBell There is no matrix field involved. Sorry, I got confused. Will edit the title. – Sven Dec 29 '16 at 9:57

There is no inherent order or hierarchy between entries in a Channel section. You could do some janky things to simulate it, but you're probably much better off converting that workArticles section to a Structured section, which does give its entries both order and hierarchy.

In your case, you might not care about the hierarchy, so you can just keep everything on the first level.

Very similar to https://craftcms.com/support/structure-nav#top-level-only

Then, if you need to, you can take advantage of all of the structure specific properties of EntryModel, (level, parent, nextSibling, etc.)

|improve this answer|||||
  • 2
    A structure does what I need. Thank you. I figured that it returns disabled items as well. So I tried {% set nextSibling = craft.entries.positionedAfter(entry).order('lft asc').first() %} but nextSibling is null. Any idea on how to get the next enabled sibling? – Sven Dec 30 '16 at 10:55
  • 2
    I figured it out! The next sibling was null because it was the last one in the structure. So in that case I am using the first sibling instead: {% set nextSibling = entry.siblings.first() %}. – Sven Dec 30 '16 at 11:39

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.