Ektron
Customizing Behavior with Extensions
Extensions are developer-defined software modules that modify the behavior of Ektron. In versions previous to 8.0, developers used the Plug-in Extension Wizard to extend the system. In versions 8.0 and higher, Extensions are preferred over the Plug-in system.
The benefits of Extensions include:
This section also contains these topics.
NOTE: onBefore
lets you manipulate the current data before it is updated. In contrast, onAfter
events do not let you change a value in the contentData object for the content being affected. onAfter
events only update data somewhere else (such as within Ektron or a third party database).
Class and Events |
---|
Ektron.Cms.Extensibility.CommunityGroupStrategy |
|
Ektron.Cms.Extensibility.ContentStrategy |
|
Ektron.Cms.Extensibility.FolderStrategy |
|
Ektron.Cms.Extensibility.MessageBoardStrategy |
|
Ektron.Cms.Extensibility.MicroMessageStrategy |
|
Ektron.Cms.Extensibility.TagStrategy |
|
Ektron.Cms.Extensibility.TaxonomyStrategy |
|
Ektron.Cms.Extensibility.UserStrategy |
|
Ektron.Cms.Extensibility.WebEventStrategy |
|
Ektron.CMS.Common Ektron.CMS.Contracts Ektron.CMS.ObjectFactory
If the assemblies are not installed in Visual Studio, you can find them in the siteroot/bin
directory.
using
statements to the top of the class.using Ektron.Cms; using Ektron.Cms.Common; using Ektron.Cms.Extensibility; using Ektron.Cms.Extensibility.Content;
Ektron.Cms.Extensibility.ContentStrategy
.namespace Cms.Extensions.Samples { public class ContentExtensionsSample : ContentStrategy { } }
NOTE: The namespace in the code above is Cms.Extensions.Samples. This information is needed for Step 8.
override OnBeforeAddContent()
. The code to modify the Title looks like this.public override void OnBeforeAddContent(ContentData contentData, CmsEventArgs eventArgs) { contentData.Title += " modified"; }
using System; using System.Collections.Generic; using System.Text; using Ektron.Cms; using Ektron.Cms.Common; using Ektron.Cms.Extensibility; using Ektron.Cms.Extensibility.Content; namespace Cms.Extensions.Samples { public class ContentExtensionsSample : ContentStrategy { public override void OnBeforeAddContent(ContentData contentData, CmsEventArgs eventArgs) { contentData.Title += " modified"; } } }
After creating the extension in the steps above, register it in the <webroot>/ObjectFactory.config
file.
This file already contains GoogleGeoCoder objectStrategies, so you need to add a new Name in the Content area. In this example, the code looks like this.
<objectFactory> <objectStrategies> <add name="Content"> <strategies> <add name="MyFirstExample" type="Cms.Extensions.Samples.ContentExtensionsSample"/> <add name="GoogleGeoCoder" type="Cms.Extensions.GoogleGeoCoder.ContentStrategy"/> </strategies> </add> <add name="User"> <strategies> <add name="GoogleGeoCoder" type="Cms.Extensions.GoogleGeoCoder.UserStrategy"/> </strategies> </add> </objectStrategies> </objectFactory>
objectStrategies
> element of the siteroot/ObjectFactory.config
file.objectStrategies
>, <add
name>
, enter a name
to identify extension type. A list of valid name
s is in the following <strategies>
element, add one or more content extensions. For each extension, insert a name
and type
. For example:<strategies> <add name="MyFirstExample" type="Cms.Extensions.Samples.ContentExtensionsSample"/> </strategies>
name
is free-text.Type
is a fully-qualified name of the extension you are registering. It consists of namespace + “.” + name of the class.More examples of Extensions are found in the Ektron SDK folder. The default location for this folder is Program Files\Ektron\CMS400SDK\CMS Extensions
. Also, sample eCommerce extensions are found in Program Files\Ektron\CMS400SDK\Commerce\Events
.