Reference

Guide

$page->hasCode()

Checks if the Files collection has any code files

$page->hasCode(): bool

Return type

bool

Example

<?php
echo $page->hasCode(); //will echo 1 if true, nothing if false

if($page->hasCode()) {
  $codeFiles = $page->code();
}
?>

What is a code file?

Kirby considers the following file types as code:

  • js
  • css
  • scss
  • rb
  • xml
  • json
  • java

Any html or php files cannot be uploaded to pages for security reasons.

Source code

kirby/src/Cms/HasFiles.php#L136