HYR
January 15, 2017, 2:17am
1
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: https://getkirby.com/docs/developer-guide/configuration/folders
I’d like to use a variable within two config files. One for each environment. For example:
config.mysite.com.php:
c::set('custom-folder', 'live-content');
config.mysite.local.php:
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:
<?php
$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)
HYR
January 15, 2017, 4:09am
3
@texnixe First, I’m always amazed at how quickly you respond. Second, your solution works like a charm (as usual)! Thanks!
1 Like
HYR
March 28, 2019, 9:17pm
5
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:
https://getkirby.com/docs/cookbook/content-structure/multisite
With the only difference, that you apply it only to the content folder.
HYR
March 28, 2019, 9:51pm
7
Boom… that worked. Thanks!