{next:ids:current_id}

Description

Returns the id that comes immediately after current_id in a dash-separated list of ids. Use it to build a forward (Next) link on a detail page: feed a list of item ids and the id of the item being shown, and next gives you the id of the following item. The list is usually a query result from ids, but any dash-separated list works (the values need not be ids). Returns an empty string when current_id is the last entry, is not found in the list, or when either argument is empty - so a Next link naturally disappears on the final item. The list is split on the dash and empty segments are dropped, so a doubled or trailing dash can break the lookup; keep the separators clean. The mirror command previous returns the id before current_id.

Parameters

ids required

Dash-separated list of ids (or any values) to step through, in order. Usually the output of {ids:...} - a query result - but any dash-separated string works. Empty segments from a doubled or trailing dash are dropped and can break the step to the next item, so keep the separators clean.

current_id required

The id whose successor you want, taken from the ids list. It must be the same id type (long or short) as the entries in ids. If current_id is the last entry, is not found in the list, or is empty, next returns an empty string.

Examples

test{next:12-34-56:34}
Expected56
Actual56
The basic shape. Given a dash-separated list and the current value 34, next returns the value that follows it, 56.
test{next:alpha-beta-gamma-delta:beta}
Expectedgamma
Actualgamma
The entries do not have to be ids - next steps through any dash-separated list. The value after beta is gamma.
test{next:12-34-56:56}
When current_id is the last entry in the list, next returns an empty string. This is how a Next link hides itself on the final item.
test{next:12-34-56:99}
If current_id is not found in the list, next returns an empty string (it does not guess or return the first item).
test{next:{ids:9e1d2b9f88e3d6c3bf0eb967378610d6}:5726c2c6b035d7aab450d1794e9e90d7}
Expected4f3362a62847fe1f8c59ba28a92d42c0
Actual4f3362a62847fe1f8c59ba28a92d42c0
The everyday pattern: feed a queried set straight into next. {ids:...} returns the ids of a slice in display order, and next gives the id that follows the current one. Here the current item is Gamma, so next returns the id of the item shown after it in that listing.
test{next:12--56:12}
A doubled dash leaves an empty segment, which next drops while keeping the original positions. That leaves a gap right after 12, so next finds nothing and returns empty even though 56 is in the string. Keep the list free of empty or trailing separators.
test{iftext:{next:12-34-56:34}:Next is {next:12-34-56:34}:no next}
ExpectedNext is 56
ActualNext is 56
The detail-page idiom, made concrete. iftext prints its middle branch only when the condition is non-empty, so a Next link shows only when a following item exists. Here 34 has a successor (56), so the Next branch is taken; on the last item next would be empty and the fallback would print instead. In a real template you feed the list of ids and the current item id from the view, then pass the result to {go:} to build the href.