Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2012-01-17 16:31:35

photonomad
Member
Registered: 2005-09-10
Posts: 290
Website

What is the best way to find the previous and next values in a list?

My article_image field contains this list of image ids: 245,239,246,238,237,251,243,241,244,236,242,250,247,240,248,249

Given one of the ids in the list, what is the easiest way to figure out the previous and next ids?

For instance, how can I return that 241 is previous and 236 is next for image id 244?

I’ve been trying to wrap my head around it with variables and txp:images and have entertained the thought of somehow using smd_each, but I am really stumped and my brain is stuck. In this particular case, tpx:images with txp:newer and txp:older will not work because I am calling the image id via a custom url variable.

I’m posting this as a new topic here, but it is also in reference to this thread

Last edited by photonomad (2012-01-17 17:18:10)

Offline

#2 2012-01-17 18:07:26

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,001
Website GitHub

Re: What is the best way to find the previous and next values in a list?

I see we’re thinking along the same lines. See that thread for an idea along these lines.


TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB