Calling all developers! We invite you to provide your input on Feature Experimentation by completing this brief survey.

 

Yugeen Klimenko
Feb 10, 2011
  3196
(0 votes)

How plugin settings are saved?

To extend UI functionality you can use plugins. One of their marvelous feature is the ability to store data entered by admin or editor. As to myself I was in curiousity about where and how these data are saved.  So I’d like to save the values of two parameters somewhere in the button click handler:

    protected void btnSave_Click(object sender, EventArgs e)

         {

             DataSet dataSet = new DataSet();

             dataSet.Tables.Add(new DataTable());

             dataSet.Tables[0].Columns.Add(new DataColumn ("Parameter1", typeof(string)));

             dataSet.Tables[0].Columns.Add(new DataColumn("Parameter2", typeof(string)));

             DataRow dataRow = dataSet.Tables[0].NewRow();

             dataRow["Parameter1"] = HttpUtility.HtmlEncode(txtParameter1.Text);

             dataRow["Parameter2"] = HttpUtility.HtmlEncode(txtParameter2.Text);

             dataSet.Tables[0].Rows.Add(dataRow);

             PlugInSettings.Save(typeof(CustomAdminPlugin), dataSet);

         }

 

OK - With a help of .NET Reflector I dug into depth of

PlugInSettings.Save(typeof(MyAdminPlugin), data) call.

 

It applies for PlugInDB in EPiServer.DataAccess namespace – namely to its SaveSettings function:

public void SaveSettings(int plugin, string xml)

    {

      base.Execute(delegate {

        IDbCommand command = this.CreateCommand("netPlugInSaveSettings");

        command.Parameters.Add(this.CreateParameter("PlugInID", plugin));

        command.Parameters.Add(this.CreateParameter("Settings", xml));

        command.ExecuteNonQuery();

      });

    }

In my case plugin is equal to 141 and xml is

<NewDataSet>
  <Table1>
    <Parameter1>value 1</Parameter1>
    <Parameter2>value 2</Parameter2>
  </Table1>
</NewDataSet>

As you can see the working horse is the netPlugInSaveSettings stored procedure. Let’s look on it:

ALTER PROCEDURE [dbo].[netPlugInSaveSettings]

@PlugInID         INT,

@Settings         NTEXT

AS

BEGIN

 

      UPDATE tblPlugIn SET

            Settings    = @Settings,

            Saved       = GetDate()

      WHERE pkID = @PlugInID

END

Conclusion : plugin’s settings are saved in tblPlugIn table , namely in xml field. This is in consistency with SDK which says “PlugInSettings is used to store plug-in settings and information in a DataSet, these will be persisted as xml together will the plug-in definition in the EpiServer database.”

 

Feb 10, 2011

Comments

Please login to comment.
Latest blogs
Optimizely Content Graph on mobile application

CG everywhere! I pull schema from our default index https://cg.optimizely.com/app/graphiql?auth=eBrGunULiC5TziTCtiOLEmov2LijBf30obh0KmhcBlyTktGZ in...

Cuong Nguyen Dinh | Jan 20, 2025

Image Analyzer with AI Assistant for Optimizely

The Smart Image Analyzer is a new feature in the Epicweb AI Assistant for Optimizely CMS that automates the management of image metadata, such as...

Luc Gosso (MVP) | Jan 16, 2025 | Syndicated blog

How to: create Decimal metafield with custom precision

If you are using catalog system, the way of creating metafields are easy – in fact, you can forget about “metafields”, all you should be using is t...

Quan Mai | Jan 16, 2025 | Syndicated blog

Level Up with Optimizely's Newly Relaunched Certifications!

We're thrilled to announce the relaunch of our Optimizely Certifications—designed to help partners, customers, and developers redefine what it mean...

Satata Satez | Jan 14, 2025