Skip to content

Kirby 4.3.0


Checks if the Files collection has any code files

$page->hasCode(): bool

Return type


Parent class



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.