21490 Posts in 5783 Topics by 2622 members
General Questions
SilverStripe Forums » General Questions » New config system - setting a module's config values from mysite/_config.php instead of module/_config/module.yml
General questions about getting started with SilverStripe that don't fit in any of the categories above.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 235 Views |
-
New config system - setting a module's config values from mysite/_config.php instead of module/_config/module.yml

21 January 2013 at 9:03pm Last edited: 21 January 2013 9:05pm
Hi,
I'm trying to bring SS3 config code more in line with the new config system. How can I set configuration values of a module outside of the module's _config/*.yml?
For example, a problem I'm trying to address is that I'm making changes to the silverstripe-googlesitemaps default configuration ie google_notification_enabled=true.
googlesitemaps/_config/googlesitemaps.yml
---
Name: googlesitemaps
---
GoogleSitemap:
enabled: true
objects_per_sitemap: 1000
google_notification_enabled: true
use_show_in_search: trueEverytime I run a composer update and a new version is downloaded, the settings that I've made are replaced with the module's default. Of course, I can merge them back after a source control diff but I'm wondering if there is a better way to do it.
Previously, in /mysite/_config.php, I'd call GoogleSitemap::enable_google_notification(); which is now deprecated. But I could simply place the new equivalent in /mysite/_config.php:
Config::inst()->update('GoogleSitemap', 'google_notification_enabled', true);
Is this the best/only approach? Or is it better to stick with modifying the _config/googlesitemaps.yml to keep in line with the new Config approach and get the performance benefits. Or would the performance benefits be negligible ?
Also from what I read in the documentation, the _config/ directory containing the YAML files seemed to be focused on modules. Another approach could be a mysite/_config/sitewide.yml where we can do site wide overrides of modules' default configuration variables? If so what would the syntax be to modify another module's configuration values?
Thanks.
Kind regards,
VWD. -
Re: New config system - setting a module's config values from mysite/_config.php instead of module/_config/module.yml

24 January 2013 at 8:20pm
Take a look at the example YAML files in framework and cms. You'll want to use After to indicate that your configuration should be loaded *after* the modules default.
http://doc.silverstripe.org/framework/en/topics/configuration has an in-depth explaination.
-
Re: New config system - setting a module's config values from mysite/_config.php instead of module/_config/module.yml

25 January 2013 at 1:04am
Thanks for your reply Will. Will give it a shot.
VWD.
-
Re: New config system - setting a module's config values from mysite/_config.php instead of module/_config/module.yml

29 January 2013 at 9:31pm Last edited: 29 January 2013 9:31pm
Here's what I did and it seems to work:
mysite/_config/sitewide.yml
---
Name: googlesitemapsoverride
After:
- '#googlesitemaps'
---
GoogleSitemap:
google_notification_enabled: trueHope it's useful to others too.
Thanks Will.
VWD
| 235 Views | ||
|
Page:
1
|
Go to Top |


