Sitefinity CMS comes with a set of built-in modules, which can be directly used in the pages you create. You can also create your own custom modules and use them side by side with the default ones.
Create a custom module
Each Sitefinity CMS module has to inherit from
ModuleBase and override the
Install method. In it, add the logic for the actions the module will perform when getting added to a Sitefinity CMS site. In this case, the module creates a backend page trough which it will be accessed and it adds ContentBlock widget to that page with some text.
EXAMPLE: To create general purpose module in Sitefinity CMS, refer to the sample module that creates sitemap by registering HTTP handler:
Following is a list of some of the methods used:
This is a mandatory method for creating specific configuraton for the module. In this sample, no configuration will be created for the module.
It is mandatory to create a manager for the module that does allow it to have its own API. In this case no manager is created.
These are optional actions that the module will do when the module is upgraded
This is a mandatory property that is used to retrieve the main backend page for the module.
This is a mandatory method that provides the logic for installing the prerequisite data for the module functionality.
Install the module
- In Sitefinity backend, navigate to Administration Modules & Services.
- Click Install a module and fill out the following fields:
To install the module, click Save.
- In Name, enter SimpleModule
- In Type, enter SitefinityWebApp.Modules.SimpleModule
This is the above CLR type of the class for the module.
- In Start module... select radio button, select When the whole application is opened for first time.
NOTE: A Sitefinity module may be functional without creating a page trough which the module is accessible
Implement custom modules
To facilitate modules decoupling, Sitefinity CMS introduces an easy mechanism for installing modules automatically. This way developers can create custom modules, which are installed automatically upon Sitefinity CMS startup. This is made possible thanks to the
SitefinityModuleAttribute assembly attribute. While the website is initializing, Sitefinity CMS looks for assemblies in the
/bin folder, containing modules marked with this attribute and installs them. The
SitefinityModuleAttribute requires you to specify your module name, type, title, description, startup type, module ID, and resource class ID if applicable. Find below an example of a Sitefinity module decorated with this attribute: