IMPORTANT: This version of Sitefinity CMS is out of support and the respective product documentation is no longer maintained and can be outdated. Use the version selector to view a supported product version.
The class should always inherit from DefinitionConfigElement and implement the interface for your custom definition. As each custom configuration class, it should provide a constructor which takes the parent configuration class as a parameter.
public
CustomConfigElement(ConfigElement parent)
:
base
(parent)
{
}
The difference between a configuration element used in definitions and a normal one, is that it implements the GetDefinition method of the base class DefinitionConfigElement. In the implementation, you should return an instance of the definition class implemented in the previous step, which corresponds to the custom config element. You can create a new instance and pass this as an argument (this is why the definition class has such a constructor).
override
Telerik.Sitefinity.Web.UI.DefinitionBase GetDefinition()
return
new
CustomDefinition(
this
);
The only thing left is to implement the definition interface and all properties it contains. Those properties should be implemented as normal configuration properties. This will let Sitefinity CMS generate user interface to edit them, as well as work with them through the configuration API.
[ConfigurationProperty(
"customHeaderText"
)]
[ObjectInfo(Title =
"Custom header text"
, Name =
"CustomHeaderText"
, Description =
"Specifies arbitrary text in the header of the control"
string
CustomHeaderText
get
(
)
[
];
set
] = value;
As you can see, configuration properties should be marked with an attribute and store/retrieve values from the dictionary that each configuration element implements. The key used in the getter and setter should always be the same, and the name used in the ConfigurationElement attribute should be the same as that key. Those three values are highlighted in the above code snippet.
Another attribute which is not required is the ObjectInfo attribute. We advise that you include that to let Sitefinity CMS know what text it should use in the user interface generated for the configuration class. You can specify the title and description that users will see in the UI. Those values will be used in the Advanced settings screen. Please take a look at the screenshot below on how they are used.
After you have implemented all properties from the definition interface as configuration properties, you can use your custom definition in your custom widgets.
Back To Top
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important