If [[~[[*id]]]] returns the current resource how do I call the previous?

My comprehension of pdotools is fairly weak so I’m looking for an easier way to paginate.

Is there a way to call the previous resource in an href?

If [[~[[*id]]]] is the current resource with an id of 10 (e.g.) how would I can I call resource 9?

Something like [[[[~[[*id]]]]-1]]

I think you could achieve your goal by using an output filter:

[[~[[*id:subtract=`1`]]]] 

// or simply just :subtract as it defaults to -1

Although I would advise against it, as this method inevitably breaks as soon as you create a resource not within you desired id order.

I don’t know your exact usecase but using pdoPage (part of pdoTools) usually works really well. Note that pdoPage will take parameters of pdoResources to define which resources you want to select and paginate.

2 Likes

pdoNeighbors does what you need.
https://docs.modx.pro/en/components/pdotools/snippets/pdoneighbors

1 Like

Thank you both. Let me investigate.