ICSEptContent Interface Content Studio 5.7 SDK
Content Studio Web Content Management System

[This is preliminary documentation and is subject to change.]

Defines methods and properties related to an EPT document content when passed in to a synchronous Event Actions event handler.

Namespace: ContentStudio.EventActions
Assembly: CS5Interfaces (in CS5Interfaces.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax

public interface ICSEptContent : IEnumerable<ICSEptField>, 
	IEnumerable

The ICSEptContent type exposes the following members.

Properties

  NameDescription
Public propertyCount
Gets the number of fields in this ICSEptContent implementation.
Public propertyFields
Public propertyItem
Gets or sets the value of a field with the specified name.
Top
Methods

  NameDescription
Public methodAddField
Adds a new field to the current ICSEptContent implementation.
Public methodContainsField
Determines whether the name represents an existing field.
Public methodGetEnumerator (Inherited from IEnumerableICSEptField.)
Public methodRemoveField
Removes a field from the current ICSEptContent implementation.
Public methodTryGetValue
Gets the value of the specified field.
Public methodTrySetValue
Sets the value of the specified field.
Top
Remarks

Note Note
This interface was added in Content Studio version 5.3
Generally, there is no need for developers to implement this interface since Content Studio already provides an implementation passed to any synchronous Event Actions event handler that implements the ICSEventHandler2 interface.
Examples

The possibility of changing document content that is about to be saved in the OnBeforeDocumentSave event opens up a number of possibilities for the programmer. For example you could combine two or more EPT-fields into another field to create a new view of the data. Before Content Studio 5.3 you had to do these kinds of operations on the client using javascript code.

The following code shows an handler that combine data from two EPT fields, FirstName and LastName, into a third field, DisplayName. The field DisplayName must exist in the schema or it will be ignored by Content Studio

//Only works in an handler that handles the OnBeforeDocumentSave event
 public class MyBeforeDocumentSaveHandler : BeforeDocumentSaveSyncHandler
 {
    protected override void DoWork()
    {
       if (DocumentStatus.IsEptDocument)
       {
          EptContent["DisplayName"] =
            String.Format("{0} {1}", EptContent["FirstName"], EptContent["LastName"]);
       }         
    } 
 }
Note Note
The following is new in Content Studio 5.5

A special case is when there are more than one field with the same name. This is not recommended but allowed. In this case all the fields sharing the same name will be combined into one single multi valued field where each field value is separated by the MultiFieldValueSeparator separator. The following code shows how to handle multi valued fields.

//Only works in an handler that handles the OnBeforeDocumentSave event
//Content Studio 5.5 and later only
 public class MyBeforeDocumentSaveHandler : BeforeDocumentSaveSyncHandler
 {
    protected override void DoWork()
    {
        if (DocumentType == DocumentTypes.EPT_Document)
        {
            if (EptContent.ContainsField("FullName") && EptContent.ContainsField("FirstName") && EptContent.ContainsField("LastName"))
            {
                var firstNames = EptContent["FirstName"].Split(new[] { EventAction.MultiFieldValueSeparator }, StringSplitOptions.None);
                var fullName = String.Join(" ", firstNames);
                EptContent["FullName"] = String.Concat(fullName, " ", EptContent["LastName"]);
            }
        }         
    } 
 }
See Also

Reference

Other Resources