Skip to content

Kirby 3.9.8

$file->prev()

Returns the previous item in the collection if available

$file->prev(\Kirby\Cms\Collection|null $collection = null): Kirby\Cms\File|null

Parameters

Name Type Default
$collection Kirby\Cms\Collection|null null

Return type

Kirby\Cms\File|null

This method does not modify the existing $file object but returns a new object with the changes applied. Learn more →

Parent class

Kirby\Cms\File

Example

if(($file = $page->file('my-file.pdf')) && $prev = $file->prev()):
    echo 'Previous file: ' . $prev->filename();
endif;