How to Link to the prev/next Document?

Hey there,

I have defined my own Subpages (Neos.Neos:Document). Now I need to integrate two buttons to go to the prev and next Document, if there is one.

I can’t really find a useful example. While I am trying to use the Flow-Query: next() it gives me weird results:

  next = Neos.Fusion:Tag {
      @process.tmpl = ${'<div class="prev"><em>' + value + '</em></div>'}
      tagName = 'a'
      attributes.href = NodeUri {
          node = ${q(node).next()}
      content = ${q(node).next().property('title')}

The weird thing here is, that in the case of the property title, I am getting the correct title of the next Document, on the other hand, the created link wrongly points to the active Document (and not the next one).

Could somebody please explain this behavior and tell me what I need to do differently?


Hi @webappcreations,

you probably have to use get(0) on the result to make that work as in:

node = ${q(node).next().get(0)}

What about the Neos.Demo site: :wink:

Thanks a lot!

1 Like

Hi @bwaidelich,

that did it for me as well.

Any hint how I would have to create the query if I would have to sort the nodes by a property first and then get the prev() or next()?



You should be able to chain those operations as usual. did you try:

${q(node).sort('someProp', 'ASC').next().get(0)}


Interesting idea. But that didn’t help. I need something like this:

${q(site).find("[instanceof document:News]").sort('date', 'DESC').???( ... now locate the current q(node) in this result ...).next().get(0)

But I just can’t figure out how to position my pointer on the correct node. Any idea?