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 ?
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 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.
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.
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 ?