Pages::slice($start[,$amount])

Version 3.7

Return a range of pages in collection in array.

Returns a new collection -object with the pages in given range.

Return value

Object Pages

Arguments

$start
Starting point.
Starts from 1
If negative, starts from end.
$amount
How many pages will be retrieved.
If not set, takes rest of the pages.

Full documentation

Print first three tasks from the Task -collection:

foreach ( $Tasks->slice(1,3)->sivut() as Task ){
    $txt .= "<p>{$Task->date} {$Task->name}</p>";
}

Print last three tasks from the Task -collection:

foreach ( $Tasks->slice(-3)->sivut() as $Task ){
    $txt .= "<p>{$Task->date} {$Task->name}</p>";
}

Print all but first three tasks from the Task -collection:

foreach ( $Tasks->slice(4)->sivut() as $Task ){
    $txt .= "<p>{$Task->date} {$Task->name}</p>";
}

Print all but last three tasks from the Task -collection:

foreach ( $Tasks->slice(1,-4)->sivut() as $Task ){
    $txt .= "<p>{$Task->date} {$Task->name}</p>";
}