Content folders for sandbox and live environments

I’d like to have a content folder for my local/sandbox development and one for my live site. My thought was to use the site.php file mentioned here:

I’d like to use a variable within two config files. One for each environment. For example:

c::set('custom-folder', 'live-content');


c::set('custom-folder', 'test-content');

I’m assuming it’s currently not possible so perhaps this is a feature request, but on the off chance that it is possible now, how would I go about doing this?

The reason why this is not possible is that site.php is loaded before the configuration.

You could try this:

$host = $_SERVER['SERVER_NAME'];

$kirby = kirby();

if($host == 'localhost') {
  // changing the directory
  $kirby->roots->content = $kirby->roots()->index() . DS . 'test-content';

  // changing the url
  $kirby->urls->content = $kirby->urls()->index() . '/test-content';

} else {
  // changing the directory
  $kirby->roots->content = $kirby->roots()->index() . DS . 'live-content';

  // changing the url
  $kirby->urls->content = $kirby->urls()->index() . '/live-content';

(not sure how reliable this is)

@texnixe First, I’m always amazed at how quickly you respond. Second, your solution works like a charm (as usual)! Thanks!

1 Like

Sleepless in Mainz…:wink:

Hey @texnixe, resurrecting this topic… How is this done in Kirby 3? My test in applying the above in the index.php errors.

Should be similar to this multisite setup:

With the only difference, that you apply it only to the content folder.

Boom… that worked. Thanks!