Dashes in variables

Hi all -

I’ve created a page called ‘case-studies’ and getting the following error:
“Fatal error: Call to a member function isErrorPage() on boolean in /var/sites/domain.co.uk/public_html/kirby/kirby/kirby.php on line 333”

Something to do with how i use dashes, but not sure what is the correct method.
My content folder is called ‘case-studies’ and inside is ‘case-studies.txt’

Where am I going wrong? Thanks!

Have you renamed the error page folder? Dashes in file names shouldn’t be a problem, but if in doubt, just try to rename the folder, file and template names.

Sorry texnixe, I’m not with you. I’ve renamed the files and folders to now have dashes and it works, so its definitely the dashes that are causing the issue. I’m just not sure how to allow them.

I don’t think there’s an option for allowing dashes. I’m using dashes in filenames myself and have never ran into any issues, so that makes it bit difficult to reproduce.

Have you checked if the error is caused by the folder name or by the name of the content file? Or both?

Thanks so much for the reply and Im sorry for the lateness in mine. I tried installed the start kit and working from scratch, but everything works without a dash, but when I add the dash it stops working!

If I enable debugging, I’m told the issue is with this line from a snippe (the snippet basically loops in existing children, and is a duplicate of the showcase snippet:

$case-studies = page('case-studies')->children()->visible();

To me, the issue of the dash in the variable creates a syntax issue, but I don’t see any other way around it.

Let me quote the docs:

Variables in PHP are represented by a dollar sign followed by the name of the variable. The variable name is case-sensitive.

Variable names follow the same rules as other labels in PHP. A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*'

So, no dashes, sorry :wink:

You can use dashes in folder names, of course. In fact, Kirby creates folders with dashes, anyway, if you use multi-word titles.

Thanks - so now I understand that in theory the dashes in a url come from the folder. However I’ve added these and it’s still broken. I’m being told that

$casestudies = page('casestudies')->children()->visible();
if(isset($limit)) $casestudies = $casestudies->limit($limit);

is wrong

I’ve included a gif of my folder structure to ensure my naming in regards to dashes is correct. Basically I just want the dash in the url for standards purposes. Thanks so much!


  • use a dash if needed as parameter for the page function. page('case-studies') since you refernce to a folder.
  • do not use dashes in php vars since thats not possibe.
  • you can name the var anything you want. it does not have to match the folder-name.
$casestudies = page('case-studies')->children()->visible(); // var without dash

As @bnomei already corrected, your variable may not have a dash in it, but your folder name does have a dash in it, so you have to use the dash in the page() helper.

Thanks! You guys and gals are awesome!