Simple Plugin UI
Creating UI for a plugin has never been easier. For the simple case of having a single settings page for your plugin, you don't need to do anything else than adding a single class to your plugin.
No HTML files, no Javascript files are needed to be added.
Template Plugin
The easiest way to create such plugin is to start by copying the Simple UI Plugin Template which is included in the SDK.
Manual Steps
- Make sure to derive your plugin class from BasePluginSimpleUI<TOptionType>
- Add another class to your project which is derived from EditableOptionsBase and name it to your liking, e.g.
PluginOptions
- Use this class for the
<TOptionType>
parameter of theBasePluginSimpleUI
base class from which your plugin is derived - Add properties to your option class. Please look at the Features section for details
Working with Options
Option Page Display
There's no further action required to display your plugin options on the Emby Server dashboard. When a user clicks on the "Settings" item of your plugin's context menu, the server will automatically create a UI page according to your options class.
Make adjustments before presentation
You are able to make adjustments to the options object before being shown at the client by overriding the @MediaBrowser.Controller.Plugins.BasePluginSimpleUI`1.OnBeforeShowUI method.
Processing Option Changes
When a user submits option changes from the UI, there are multiple ways to interact with that submission:
Validation
This is the primary and preferred way for validating user input.
Please see Validation for details and an example.
Override OnOptionsSaving
Allows to cancel saving options to disk.
Override OnOptionsSaved
Override OnOptionsSaved
to get notified about option changes.
Accessing Options from your Plugin
You can call the GetOptions()
and SaveOptions()
methods of the plugin base class to retrieve or save your options data.
Option Page Visibility
By default, the option page will only be accessible by navigating to the "Plugins" section on the server dashboard and select the "Settings" context menu entry on your plugin.
This is the recommended way and should be sufficient for most plugins.
Only when your plugin provides significant extra value other than just some settings, you can add your plugin UI page to be shown as a separate entry in the navigation bar of the server dashboard.
To do so, override the OnCreatePageInfo()
method of the base class and adjust the properties of the PluginPageInfo object accordingly.