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.
NOTE: Depending on your use case scenario, the officially recommended approach whether to proceed by creating a custom module is as follows:
- For modules, that serve as extensibility points for your Sitefinity CMS functionality (for example, adding integration, widgets, logic, and so on), when the out of the box functionality must be extended, use custom modules.
- If you want to define new content types in Sitefinity CMS, the officially recommended approach is to use Dynamic modules and the Module Builder.
Create a custom module
Each Sitefinity CMS module must inherit from the
ModuleBase class and override the
Install method. In it, add the logic for the actions the module performs when getting added to a Sitefinity CMS site. For example, registering some configuration, creating backend pages, adding widgets and so on.
Developers can leverage the Sitefinity VSIX and CLI tools to get started with building custom modules. Both Sitefinity VSIX and Sitefinity CLI enable you to add a new custom module project with the necessary scaffolded module classes, containing inline guidance.
EXAMPLE: To create a general purpose module in Sitefinity CMS, with minimum implementation effort, refer to the sample Database diagnostic module available on the Sitefinity GitHub repository The module class contains inline documentation for each method used and can guide you into the purpose of each of them.
Install the module
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.
Implement custom modules
In addition to the full implementation of the Database diagnostic module, discussed above, below you can find below an example of a dummy Sitefinity module that you can use as a scaffolding for your custom implementations if you prefer to start from scratch: