Skip to content

Kirby 4.4.1

$page->hasCode()

Checks if the Files collection has any code files

$page->hasCode(): bool

Return type

bool

Parent class

Kirby\Cms\Page

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.