Kentico CMS 7.0 Developer's Guide

Writing custom providers

Writing custom providers

Previous topic Next topic Mail us feedback on this topic!  

Writing custom providers

Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic!  

Providers in Kentico CMS are classes that allow the system to manipulate objects and perform various actions. The following list presents the providers that the system uses and their purpose:

 

Info providers contain methods for working with specific types of objects stored in the database, such as users, contacts, custom table records, etc.

Data provider handles low-level database operations. The Info providers are built on top of the Data provider and use it to store and fetch data.

E-mail provider manages the e-mail queue and sends e-mails.

Search provider ensures the functionality of the SQL search.

Storage providers allow you to access various file systems. They extend the CMS.IO namespace. See File system access API for information how to write a custom file system provider.

 

By developing custom providers and using them instead of the standard ones, you can modify the behavior of the application (or a specific module) according to your exact requirements.

 

Adding your custom code files

 

When developing custom functionality, you can place your code files in:

 

The App_Code folder (named Old_App_Code if you use a web application project)

A separate project (assembly) integrated into the main web project

 

Placing your customizations into the App_Code folder ensures that the code is compiled dynamically when required and automatically referenced in all other parts of the application.

 

Writing the custom code

 

Every class used to customize the application must inherit from the original class. This allows you to implement your modifications or additions by overriding the members of the given class. When creating overrides for existing methods, it is recommended to call the original base method within your custom code.

 

You can find information about the available provider, helper and manager classes in the Kentico CMS API reference, including their inheritance hierarchy and lists of methods.

 

Registering custom providers

 

After you write the code, you must register your custom classes to ensure that the system uses them instead of the default providers. You can choose between two options of registering custom provider classes:

 

In App_Code using the CMSModuleLoader partial class - the most straightforward way to register providers.

Using the web.config file - allows you to switch between different providers (custom or default) without having to edit the application code.

 

Other customization options

 

In addition to providers, you can also customize the following helper classes:

 

Helper Class Name

Namespace

Description

AutomationHelper

CMS.DataCom.Automation

CMS.SalesForce.Automation

These two helper classes provide marketing automation support for common actions related to Data.com and SalesForce integration.

CacheHelper

CMS.GlobalHelper

Handles operations with cache items.

ClassHelper

CMS.SettingsProvider

Takes care of dynamically loaded classes and assemblies.

CookieHelper

CMS.GlobalHelper

Contains methods for managing cookies.

DirectoryHelper

CMS.IO

Manages directories in the file system.

LeadReplicationHelper

CMS.SalesForce

Replicates contacts into SalesForce leads.

MediaHelper

CMS.GlobalHelper

Provides methods for rendering media content.

OutputHelper

CMS.OutputFilter

Manages the HTML output and the output cache.

SyncHelper

CMS.Synchronization

Synchronizes document and object data to other instances of the application when using Content staging.

TransformatonHelper

CMS.Controls

Provides methods that can be used in ASCX transformations.

 

You can also use global event handlers to customize the behavior of the system. Handlers allow you to execute custom code whenever a specific event occurs in the system, such as document or object changes, various parts of the user authentication process, etc.

 

Examples

 

Custom Info provider - demonstrates how to customize standard Info providers.

Custom E-mail provider - shows a sample customization of the e-mail provider. Uses the web.config extensibility section to register the custom provider.

Custom Data provider - describes the specific steps that you need to take to customize the Data provider.

Custom SQL search provider - demonstrates how you can modify the SQL search provider.