When developing custom extensions using plugins, it is often beneficial to install UI components as part of the installation of the extension making use of the IInstallallablePlugin interface and the theme automation API.
[toc]
What is the Theme Automation API
The theme automation API is set of APIs made available to plugins via the in-process API to enable the automated adjustment of UI components. Specifically, it includes the following services:
ContentFragments | Enable/disable widgets, identify widgets to other theme automation APIs, translate widgets, and automate widget upgrading (see Managing Widget Source and Distribution). |
FactoryDefaultScriptedContentFragmentProviderFiles | Add/update, delete, and detect factory default widget provider source files and attachments to install files associated to a factory default widget provider (IScriptedContentFragmentFactoryDefaultProvider plugin). For the recommended approach to deploy factory default widgets, see Managing Widget Source and Distribution. |
ThemeFiles | Add/update and detect embedded theme files. |
ThemeFooterContentFragments | List, insert, replace, and delete widgets within theme footers. |
ThemeFooters | Add, edit, delete, and detect theme footers. |
ThemeHeaderContentFragments | List, insert, replace, and delete widgets within theme headers. |
ThemeHeaders | Add, edit, delete, and detect theme headers. |
ThemePageContentFragments | List, insert, replace, and delete widgets within theme pages. |
ThemePages | Add, edit, delete, and detect theme pages. |
Themes | List themes for a specific theme type. |
And the following sets of constants for use with the services:
ContentFragmentWrappingFormats | Constants for platform-defined widget wrapping formats for use with content-fragment-related services. |
LayoutRegions | Constants for platform-defined layout regions for use with widget placement in content-fragment-related services. |
ThemeableApplicationIds | Constant for identifying the site application identifier. |
ThemeProperties | Constants for theme properties used to interact with the ThemeFiles service. |
ThemeTypes | Constants for the platform-defined theme types to be used with other theme automation APIs. |
Example: Installing a CSS File
TBD
using System; using System.Text; using Telligent.Evolution.Extensibility.Version1; using Telligent.Evolution.Extensibility.UI.Version1; namespace Samples { public class InstallCssFile : IPlugin, IInstallablePlugin { private readonly string _fileName = "sample.css"; private readonly System.IO.Stream _fileStream = new System.IO.MemoryStream(Encoding.UTF8.GetBytes(@".content-fragment-page { background-color: #f00; }")); #region IPlugin Implementation public string Name { get { return "Install a CSS File Sample"; } } public string Description { get { return "Installs a CSS File in the Site theme."; } } public void Initialize() { } #endregion #region IInstallablePlugin Implementation public Version Version { get { return new Version(1, 0); } } public void Install(Version lastInstalledVersion) { foreach (var theme in Themes.List(ThemeTypes.Site)) { ThemeFiles.AddUpdateFactoryDefault( theme, ThemeProperties.StyleSheetFiles, _fileName, _fileStream, (int)_fileStream.Length, new CssThemeFileOptions { ApplyToModals = true, ApplyToNonModals = true }); ThemeFiles.AddUpdate( theme, ThemeableApplicationIds.Site, ThemeProperties.StyleSheetFiles, _fileName, _fileStream, (int)_fileStream.Length, new CssThemeFileOptions { ApplyToModals = true, ApplyToNonModals = true } ); } } public void Uninstall() { foreach (var theme in Themes.List(ThemeTypes.Site)) { ThemeFiles.RemoveFactoryDefault(theme, ThemeProperties.StyleSheetFiles, _fileName); ThemeFiles.Remove(theme, ThemeableApplicationIds.Site, ThemeProperties.StyleSheetFiles, _fileName); } } #endregion } }