Skip to content

Kirby 5.0.2

$page->hasCode()

Checks if the Files collection has any code files

$page->hasCode(): bool

Return type

bool

Parent class

Kirby\Cms\Page

What is a code file?

Kirby considers the following file types as code:

  • css
  • js
  • json
  • java
  • rb
  • py
  • scss
  • xml
  • yaml
  • yml

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

Examples

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

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