Hi there,
The other day I needed to incorporate settings in a custom made Page Plugin.
I didn't want to edit the web.config of Kooboo, because that would create a lot of rubbish in the end.
1) I created a Page Plugin specific configuration file, called my.config. As you can see, the structure of the configuration file looks just like a regular .net configuration file.
Code:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="foo" value="bar" />
</appSettings>
</configuration>
2) I uploaded my.config into the root of the file manager under Development - Files.
3) In code, I can now reference to my.config by doing this:
Code:
var path = Path.Combine(pageViewContext.PageRequestContext.Site.PhysicalPath, "Files", "my.config");
var configMap = new ExeConfigurationFileMap
{
ExeConfigFilename = path
};
var config = ConfigurationManager.OpenMappedExeConfiguration(configMap, ConfigurationUserLevel.None);
var section = (AppSettingsSection)config.GetSection("appSettings");
var response = pageViewContext.ControllerContext.HttpContext.Response;
response .Write("Value of foo = " + section.Settings["foo"].Value + "<br />");
That's all there is to it. Enjoy!