Modify config options from the panel

Hello everyone,

I search and didn’t find over the forum, guide, cookbooks and docs the right way to modify a config option via the panel.

I attempt to create a Maintenance mode that the user can set or not. I first use $site options BUT as multilang website it’s a bit nonsense to ‘translate maitenance mode…’. It would resume to click each language and not to forget any to put the whole site in maintenance. The same on the way back…

I found Config::set() wich appears to be the perfect solution but the question is what is the right way to use it in the panel ?

Thanks for your advises !


In your config, you can only fetch content from pages or the site within the ready config option (because calling kirby() or site() in the config will lead to an error).

So you would set your config option within ready.

Thanks for the reply :slight_smile: I read about that.

So if we can’t modify the config.php from the panel what would be the best bet to let the user put a ‘Maintenance Mode’ from the panel in a multilang context ?

I would prevent the editing of config.php by hand.

Thanks a lot,

I’m not saying you can’t, I wrote that you need to set such a config option that you want to control from the Panel from within the ready option.

Ok thanks ! I read some things on another post and I tought it was not possible.

And another question : what is the right way to trigger route or php function from vue component in the panel ?

What I would like to do : In the vue component I would like to click on the toggle button, then call a php method to activate Config::set(‘maintenance’, true).

I was thinking of creating a route + action for that, but what I ignore is how to call that route from Vue.

Thanks and all the best !

That won’t work, you cannot change your config settings like that. Config options need to be set in the config, in a plugin or when a Kirby instance is created. What you need is to store a value in the site object or so and then query this value in the ready config option, so that it is available on any call.

So not sure what you are creating this component for?

Thanks ! That confirm that I first understood about that…

My goal is to make a Maintenance mode easily editable by the users in the panel. The main issue is : because my website is multilang, using a $site option force me to check maintenance option in each language… We have about 8 languages… Not optimized I think.

Another option is to watch Maintenance page status (published or not) but it looks to me like a poor option, no ?

Have a nice day,

Why, you can use a toggle field with translate: false setting, so only set it in the default language.

Oh sounds great ! I’ll check that ! Thanks