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 us 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 add 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 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. For example, registering some configuration, creating backend pages, adding widgets to them and so on.
Developers can leverage the Sitefinity VSIX and CLI tools to get started with building custom modules. Both Sitefintiy VSIX and Sitefintiy 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 aluminum 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: