It’s been quite a long time I am seeing so many questions in ektron developer forum regarding customizing the behaviour of ektron. Many of them want to perform some action when something is happened in workarea, the central interface of ektron CMS. Some of them want to do things before happening something and so on.
This blog post is for those ektron developers who want to leverage the capabilities CMS Extensions in ektron to customize the behaviour of Ektron CMS.
CMS Extensions in Ektron:
Software Extensions are fundamentally intended to extend the capabilities of a software system. Similarly a CMS Extension is capable of broadening the potential of a CMS as per the requirement. CMS Extensions was introduced in ektron with the release of Ektron 8.0.This software extensibility framework allows developers to define software modules which will modify the behavior of the CMS.
Here, the activities occurs in the CMS is exposed to the Extension Framework through event handlers, which can be overridden by the developers to meet their specific requirement.
Now let us take the following scenario to develop an extension:
Suppose I am developing a demo site for Suyati with ektron in which the content authors will publish contents through ektron workarea. Whenever a new content is added to the CMS with the word “Suyati”, I need to make that word bold through the Extension module.
So how do I build this extension module?
The steps involved in creating a new extension involve the following:
So I am going to create a new Class library, named “ContentExtenstionSample”. And I am going to add references to the following ektron DLL’s in order to use the Extension API’s.
Now let us create a class to add the extension logic.
This class should be inherited from the “ContentStrategy” class in the Ektron.Cms.Extensibility namespace as we are dealing with the contents here.
Few of the other strategies provided by ektron involve:
Now I am adding one more class named “ProcessContent” to write a static method to process the content and enable bold for the keyword “Suyati”.
Now let us compile the DLL and place that in the Ektron site’s bin folder, and the next step is to register the DLL in <webroot>/ObjectFactory.config file.
If you look at this config file, you could see the entries of extensions which are registered to the CMS by default. Now we are going to add a new one under the section “Content”.
You can add a new name for this entry, and the type goes like this,
Type=”Namespace.Class Name”,”Assembly Name”
In our case the namespace is ‘Cms.Extensions.Samples’ and class name is ContentExtensionSample.The assembly name is ‘Cms.Extensions.Samples’. Once we are done with this we can go and test our extension, For that, I am going to add a new content to the workarea.
This typical content is a client testimonial, and it has got multiple occurrences of the keyword “Suyati” in it.
The content looks like this before publishing it:
Now we will check the content after publishing it,
Yes! All the keywords “Suyati” has become bold after publish!
Thus, we are just done with a sample CMS Extension!