This topic explains how to register a module with Sitefinity. Again, as stated earlier, the Contacts module is used as an example of a custom
module.
The module contains two projects: Sample.Contacts and Sample.Contacts.Data. You can download the necessary files HERE.
Creating the Project
Add both of these projects to an existing Web site project in Visual Studio which will make use of the Contacts module. If the Web
site already has a solution, just add these two projects to it. If not, create a solution. Then, add both projects as references to the WebSite project (Sitefinity
WebSite).
 |
When setting up the Contacts project, there might be errors with the references of the two added
solutions (Sample.Contacts and Sample.Contacts.Data). If so, just delete these references in the References
folder of each solution that has a yellow triangle and add the corresponding .dll files from the bin folder of the Web site
project instead. |
Registering the Module
web.config's <section> tag
Add the config section for the Contacts module to the web.config file. Find in the web.config file the
<configSections> tag, and then inside it the <sectionGroup name=”telerik”> tag. There, add the code content in the
<section name"contacts" ...> tag as shown below:
| Section Tag |
Copy Code |
|
<configSections>
<sectionGroup name ="telerik">
<section
name="contacts"
type="Sample.Contacts.Configuration.SectionHandler, Sample.Contacts"
requirePermission="false"/>
...
</sectionGroup>
</configSections>
|
Sample.Contacts is the name of the project. SectionHandler is the class inheriting the base class ConfigurationSection and it
contains the functionality for loading and accessing the contacts section information.
web.config's <telerik> tag
Add the <contacts...> section inside the section formed by the <telerik> tag. The <contacts>
section will allow you to set various settings required by the Contacts module. Find the <telerik> element and add the code shown
below for the Contacts module.
 |
The <telerik> tag must be an immediate parent of the <contacts>
section. |
| Contacts Tag |
Copy Code |
|
<telerik>
...
<contacts defaultProvider =““>
<providers>
<clear/>
<add
name="Sitefinity"
securityProviderName=""
type="Sample.Contacts.Data.DefaultProvider, Sample.Contacts.Data"
connectionStringName="DefaultConnection"
visible="true"
controlPanelListTemplate="~/Sitefinity/Admin/ControlTemplates/Contacts/ControlPanelListTemplate.ascx"
controlPanelInsertEditTemplate="~/Sitefinity/Admin/ControlTemplates/Contacts/ControlPanelInsertEditTemplate.ascx"
contactsPermissionsTemplate="~/Sitefinity/Admin/ControlTemplates/Contacts/ContactsPermissionsTemplate.ascx"
contactEditorTemplate="~/Sitefinity/Admin/ControlTemplates/Contacts/ContactEditorTemplate.ascx"
commandPanelTemplate="~/Sitefinity/Admin/ControlTemplates/Contacts/CommandPanelTemplate.ascx"
contactsListTemplate="~/Sitefinity/ControlTemplates/Contacts/ContactsListTemplate.ascx"
singleContactTemplate="~/Sitefinity/ControlTemplates/Contacts/SingleContactTemplate.ascx"/>
</providers>
</contacts>
</telerik>
|
The most rudimentary setting we need to set is the provider for this module. Sample.Contacts.Data is the data project for the Contacts
module and the defaultProvider is the class providing an implementation for the provider model.
web.config's <framework> tag
Finally, the module must be registered. The previous two steps were required for the module itself, while this last step actually registers the module in Sitefinity.
Find the <framework> element, then <modules> element inside of it. Add the code shown in the <add> tag,
inside the <modules> element.
| Framework Tag |
Copy Code |
|
<framework>
<modules>
...
<add type="Sample.Contacts.ContactsModule, Sample.Contacts"/>
</modules> </framework>
|
In the code above, ContactsModule is the class which provides substantial information for the custom module. That is the main module class - it
inherits the WebModule class.
Next Topic
In the topic Modules Structure you can find some specifications of the Contacts module and some code
examples.