ECL Event Handler

This eXtension contains an event handler which is triggered on the creation of ECL stub Components and can copy ECL external metadtata to the metadata of the ECL Component so it can be published to the Broker for example.

The event handler subscribes to the Component Save event, and can be configured to do this synchronously or asyncronously. The benefit of doing it synchronous is that the update will happen inside the save action, but that might have a negative performance impact on the save action. Thus the alternative option is made available to make this happen asynchronously. An extra save will occur outside of the inital save action (on first creation of the ECL stub Component). 

Configuration is done by means of a so called app.config file (EclStubComponentEventHandler.dll.config) which is placed right besides the event handler DLL. The configuration contains the following:

  1. MetadataXmlFieldName - Metadata XML field name from the ECL Schema (used for ECL Metadata and Stub Metadata)

  2. MountpointType - MountPoint type, as configured in ExternalContentLibrary.xml (so this event will only be fired for a specific ECL provider)

  3. Asynchronous - true or false

  4. Update - true or false (Set to "true" if metadata needs to be updated on every save if different, "false" will only insert metadata when field is empty)

It is designed as an example to show how you can with the ECL stub Component creation and interact with that. It is currently configured to copy the Description field of the ECL external metadata to the ECL metadata. So before installing this event handler you have to add a Description (single line Text field) to the Flickr ECL Schema (else the event handler will not fire). The source is available in the download package below and also on Google code as an open source project.

Installation

This eXtension comes with full source as a Microsoft Visual Studio solution which you can directly compile and deploy (you can use the free Microsoft Visual Studio Express edition). To install the event handler you need to place the assembly on the SDL Tridion Content Manager server and register it as described in the following steps.

  1. Start with shutting down the following services on your Content Manager server:
    1. IIS
    2. Any SDL Tridion-related COM+ services
    3. The Publisher service of SDL Tridion
  2. Compile the solution to a .NET assembly and store on your Content Manager server
  3. Open the configuration file called Tridion.ContentManager.config, located in the config/ subfolder of the Content Manager root location (typically C:\Program Files\Tridion\), in a plain-text or XML editor. Find the extensions element in this file. If the element is empty (that is, if it reads <extensions/>), replace it with <extensions></extensions>. Then add a line of the following format:

    <add assemblyFileName="C:\path\to\EclStubComponentEventHandler.dll" />

    If the element was empty, the fragment should now read:

    <extensions>
        <add assemblyFileName="C:\path\to\EclStubComponentEventHandler.dll" />
    </extensions>
  4. Save and close Tridion.ContentManager.config
  5. Configure C:\path\to\EclStubComponentEventHandler.dll.config to your liking
  6. Restart the services you stopped

You can now use your Content Manager as you normally do. When linking to an ECL item for the firt time, a Stub Component will be created, and its empty metadata field will be set by the event handler with the value from the ECL external metadata field.

Background information

More information about ECL and how to create ECL providers can be found in the SDL Tridion documentation:

  1. Developing a Provider (ECL) (login required)
  2. External Content Library concepts and API (login required)
  3. ECL Template Building Block
  4. Flickr ECL provider
  5. YouTube ECL provider

A full description of this event handler and its usage is available on the Tridion Developer blog.


Developer
:    Bart Koopman
Company
License agreement
Download package
Tags
:    Event System,  2013,  ECL
Version
:   1.0
Source
:   Yes

About the Author
Bart Koopman
Community Development Consultant

As a Community Development Consultant, Bart is the evangelist of all SDL Tridion products. Bart used to be a consultant and trainer at SDL Tridion, supporting both partners and customers with their implementations.

SDL CMT division