Reference

Guide

$page->hasDocuments()

Checks if the Files collection has any document files

$page->hasDocuments(): bool

Return type

bool

Example

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

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

What is a document file?

Kirby considers the following file types as document:

  • text
  • mdown
  • md
  • markdown
  • pdf
  • doc
  • docx
  • dotx
  • word
  • xl
  • xls
  • xlsx
  • xltx
  • ppt
  • pptx
  • csv
  • rtf
  • rtx

Source code

kirby/src/Cms/HasFiles.php#L140