{limit:ids:offset:length:delimiter}

Description

Returns a slice of a delimited list - typically a list of item ids. It works like the PHP array_slice() function: offset is the 0-based start position and length is how many entries to keep. Both offset and length may be negative (counted from the end of the list). The result is re-joined with the same delimiter. Leading and trailing whitespace and a single-character delimiter are trimmed off the input before splitting. The most common use is take the first id: limit a list to offset 0, length 1.

Parameters

ids required

The delimited list to slice, usually a list of item ids. Split on the delimiter after trimming surrounding whitespace and a single-character delimiter from both ends.

offset required default 0

0-based start position. A negative offset counts from the end of the list (so -2 starts at the second-to-last entry). Non-integer text is read as 0.

length optional default to the end of the list

How many entries to keep. Omit it to take everything from offset to the end of the list. A negative length stops that many entries before the end of the list. Length 0 returns an empty result.

delimiter optional default - (dash)

The separator between entries, used both to split the input and to re-join the result. May be more than one character.

Examples

virtual{item:{limit:{relation.......1}:0:1}:_#PHOTO___}
Expected(the first linked photo)
From a production RSS feed. relation.......1 holds a list of linked photo ids; limit keeps just the first one, and item renders that single photo. The output depends on the current item, so this example is illustrative rather than asserted.
test{limit:alfa-beta-gamma-delta-epsilon:0:1}
Expectedalfa
Actualalfa
The most common use: offset 0, length 1 returns just the first entry. This is how you pick the lead photo or the first id out of a query.
test{limit:alfa-beta-gamma-delta-epsilon:0:3}
Expectedalfa-beta-gamma
Actualalfa-beta-gamma
Offset 0 with a length of 3 keeps the first three entries, re-joined with the dash delimiter.
test{limit:alfa-beta-gamma-delta-epsilon:2}
Expectedgamma-delta-epsilon
Actualgamma-delta-epsilon
With no length parameter, everything from the offset to the end of the list is returned. Offset 2 drops alfa and beta.
test{limit:alfa-beta-gamma-delta-epsilon:-2}
Expecteddelta-epsilon
Actualdelta-epsilon
A negative offset counts from the end of the list. Offset -2 starts at the second-to-last entry and (with no length) runs to the end.
test{limit:alfa-beta-gamma-delta-epsilon:0:-1}
Expectedalfa-beta-gamma-delta
Actualalfa-beta-gamma-delta
A negative length stops that many entries before the end. Length -1 keeps everything except the last entry.
test{limit:alfa-beta-gamma-delta-epsilon:1:2}
Expectedbeta-gamma
Actualbeta-gamma
Offset 1, length 2 returns two entries starting at the second one.
test{limit:a,b,c,d,e:1:2:,}
Expectedb,c
Actualb,c
The fourth parameter sets the separator used both to split the input and to re-join the result. Here a comma is used instead of the default dash.
test{limit:alfa-beta-gamma-delta-epsilon:9:1}
When the offset is beyond the last entry, the result is empty - there is nothing to slice.
test{limit:{ids:9e1d2b9f88e3d6c3bf0eb967378610d6}:0:1}
Expectedce4ac95c48c3bbe590b80794e47c3e7b
Actualce4ac95c48c3bbe590b80794e47c3e7b
The real-world pattern. ids returns a dash-joined list of matching item ids; limit with offset 0 length 1 narrows it to the single first id, ready to feed into item. (Uses the frozen AA Test Data - Stable slice for a deterministic result.)