slice

Description

Returns a portion of a list.

 list slice( list input, integer offset [, integer length ] )

Given a list, returns a portion of that list.

  • offsetis the index (starting at 0) of the item to start slicing at.
  • lengthis the number of items to return in the slice.
  • If lengthis not passed, the rest of the list will be returned.

Example

 {slice([10, 20, 30, 40, 50], 1, 2)} ---> [20, 30] 
 {slice([10, 20, 30, 40, 50], 2)}    ---> [30, 40, 50]

This function can also be used in a {foreach} loop in the code of a template or campaign. It will limit the number of stories included from a data feed. See details of coding a template for a data feed here.

{foreach slice(content,0,5) as c}
Top