Skip to content

Kirby 5.1.1

$page->hasDocuments()

Checks if the Files collection has any document files

$page->hasDocuments(): bool

Return type

bool

This method modifies the existing $page object it is applied to and returns it again.

Parent class

Kirby\Cms\Page

What is a document file?

Kirby considers the following file types as document:

  • csv
  • doc
  • docx
  • dotx
  • indd
  • md
  • mdown
  • pdf
  • ppt
  • pptx
  • rtf
  • txt
  • xl
  • xls
  • xlsx
  • xltx

Examples

echo $page->hasDocuments(); //returns the number of documents in the folder

if ($page->hasDocuments()) {
  $documents = $page->documents();
}