Simple way to make your plug-in settings editable
There is a plug-in manager in admin mode in EPiServer. You can view all plug-ins that you have installed in your site and enable or disable plug-ins.
Besides that you can even have your plug-in setting edited there.
It is really easy to implement it and configuration page will take care of save operation for you. And you need only add one attribute on your property in your class. In this example we will create a plug-in with class name "myplugin" and "myplugin" has a setting with name "mypluginsetting1" and we want this setting be editable as Textbox in plug-in configuration page:
1: public namespace myns
2: { 3: [GuiPlugIn(RequireLicenseForLoad = false)]
4: public class myplugin
5: { 6: public myplugin()
7: { 8: }
9: private string _mypluginsetting1;
10: [PlugInProperty(Description = "mypluginsetting1.", AdminControl = typeof(TextBox), AdminControlValue = "Text")]
11: public string mypluginsetting1
12: { 13: get { return _mypluginsetting1; } 14: set { _mypluginsetting1 = value; } 15: }
16: }
17: }
"AdminControl" is the type of user control you want to use in the configuration page. "AdminControlValue" is property of that user control that contains value. I.e Text for TextBox and Checked for CheckBox.
To use the "mypluginsetting1" you need do following code:
1: myplugin setting = new myplugin();
2: PlugInSettings.AutoPopulate(setting);
3: string s = setting.mypluginsetting1;
More documentation could be find here and here. And Marek has also write about this attribute. I write it again because I think this attribute need more attention.
27 August 2008