When developing a module for Sitecore CMS that is going to be shared with a wider public or customizing the Sitecore functionality, the following implementation specific questions may arise:
- What are the common rules for module implementation?
- How to avoid most typical architecture mistakes?
- How not to mix up the module parts with other Sitecore components?
This article provides some basic and generally suggested practices to cover these and some other questions that Sitecore developers may have.
Architecture
- Avoid using web services for communication between instances because they might be protected by firewalls that don't allow inbound or outbound connections. Use the EventQueue mechanism instead.
- Keep in mind the performance of your module in case of a high load, perform load testing. This should guarantee the stability of your module on production instances.
- Make your module culture independent because there is always a chance that it will run in a context of a different culture.
Code
Items
- Place module specific layout items as well as views, renderings and sublayouts in /sitecore/layout/Layouts/Modules/<ModuleName>.
- Store module specific templates in the /sitecore/templates/Modules/<ModuleName> item-folder.
- Avoid modifications of default Sitecore items and templates unless absolutely necessary.
- If you need to extend the Standard Template with custom fields, do it according to the steps below:
- Create a section template beneath the /sitecore/templates/System/Templates/Sections item and set {00000000-0000-0000-0000-000000000000} as a base template.
- Add necessary fields to the section template.
- Add the section template to the list of base templates for the /sitecore/templates/System/Templates/Standard template.
Settings
- The settings that are supposed to be relatively constant and changed only by developers/administrators should be stored in configuration files.
- Use the /App_Config/Include/Sitecore.<ModuleName>.config file to store module specific settings and to patch the Sitecore configuration.
- Settings that are going to be changed often or contain links to Sitecore items should be stored in items to make use of the Links Database and the Broken Links report.
- Settings items should be located in the /sitecore/system/modules/<ModuleName> item-folder.
- Site-specific settings in multisite solutions should be stored in either the <site name="website" ... /> configuration element or the /sitecore/content/website/<ModuleName>Settings item referenced by the <site name="website" <moduleName>Settings="/sitecore/content/website/<ModuleName>Settings" /> element.
Package
- Avoid using post step install actions that interact with a user, as it prevents a module from being installed automatically with script.
- Avoid using post step install actions for installing nested or dependent Sitecore Packages as it prevents control of conflict situations.