API Docs for: 1.5.0
Show:

ContentTypeService Class

Creates an instance of content type service object. Should be retrieved from CAPI instance (see example).

Note on the callbacks usage

The callback argument of the service methods always take 2 arguments:

  • **error** either false or CAPIError object when an error occurred
    
  • **response** the Response object
    

Example:

var contentTypeGroupCreateStruct = contentTypeService.newContentTypeGroupInputStruct(
    "new-group-id"
);

contentTypeService..createContentTypeGroup(
    "/api/ezp/v2/content/typegroups",
    contentTypeGroupCreateStruct,
    function (error, response) {
       if (error) {
           console.log('An error occurred', error);
       } else {
           console.log('Success!', response);
       }
});

Constructor

ContentTypeService

(
  • connectionManager
  • discoveryService
)

Parameters:

  • connectionManager ConnectionManager

    connection manager that will be used to send requests to REST service

  • discoveryService DiscoveryService

    discovery service is used for urls auto-discovery automation

Example:

var contentTypeService = jsCAPI.getContentTypeService();

Methods

addFieldDefinition

(
  • contentTypeId
  • fieldDefinitionCreateStruct
  • callback
)

Add a new field definition to the target Content Type draft

Parameters:

  • contentTypeId String

    target content type identifier (e.g. "/api/ezp/v2/content/types/18")

  • fieldDefinitionCreateStruct FieldDefinitionCreateStruct

    object describing the new field definition to be created

  • callback Function

    callback executed after performing the request (see Note on the callbacks usage for more info)

assignContentTypeGroup

(
  • contentTypeId
  • groupId
  • callback
)

Assign the target content type to the target content type group

Parameters:

  • contentTypeId String

    target content type identifier (e.g. "/api/ezp/v2/content/types/18")

  • groupId String

    target content type group identifier (e.g. "/api/ezp/v2/content/typegroups/2")

  • callback Function

    callback executed after performing the request (see Note on the callbacks usage for more info)

copyContentType

(
  • contentTypeId
  • callback
)

Make a copy of the target content type

Parameters:

  • contentTypeId String

    target content type identifier (e.g. "/api/ezp/v2/content/types/18")

  • callback Function

    callback executed after performing the request (see Note on the callbacks usage for more info)

createContentType

(
  • contentTypeGroupId
  • contentTypeCreateStruct
  • publish
  • callback
)

Create a content type

Parameters:

  • contentTypeGroupId String

    target content type group identifier (e.g. "/api/ezp/v2/content/typegroups/1")

  • contentTypeCreateStruct ContentTypeCreateStruct

    object describing the new content type to be created

  • publish Boolean

    weather the content type should be immediately published or not

  • callback Function

    callback executed after performing the request (see Note on the callbacks usage for more info)

Example:

var contentTypeCreateStruct, fieldDefinition;

contentTypeCreateStruct = contentTypeService.newContentTypeCreateStruct(
     "some-id", "eng-US", [{
         "_languageCode":"eng-US",
         "#text":"Some Name"
     }]
);

fieldDefinition = contentTypeService.newFieldDefinitionCreateStruct(
    "my-new-field", "ezstring", "content", [{
        "_languageCode":"eng-US",
        "#text":"Subtitle"
    }]
);

contentTypeCreateStruct.body.ContentTypeCreate.FieldDefinitions.FieldDefinition.push(fieldDefinition.body.FieldDefinitionCreate);

contentTypeService.createContentType(
    "/api/ezp/v2/content/typegroups/1",
    contentTypeCreateStruct,
    true,
    callback
);

createContentTypeDraft

(
  • contentTypeId
  • contentTypeUpdateStruct
  • callback
)

Create a new content type draft based on the target content type

Parameters:

  • contentTypeId String

    target content type identifier (e.g. "/api/ezp/v2/content/types/18")

  • contentTypeUpdateStruct ContentTypeUpdateStruct

    object describing changes to the content type

  • callback Function

    callback executed after performing the request (see Note on the callbacks usage for more info)

Example:

var contentTypeUpdateStruct = contentTypeService.newContentTypeUpdateStruct();

contentTypeUpdateStruct.names = {};
contentTypeUpdateStruct.names.value = [{
    "_languageCode":"eng-US",
    "#text":"My changed content type"
}]

contentTypeService.createContentTypeDraft(
    "/api/ezp/v2/content/types/18",
    contentTypeUpdateStruct,
    callback
);

createContentTypeGroup

(
  • contentTypeGroups
  • contentTypeGroupCreateStruct
  • callback
)

Create a content type group

Parameters:

  • contentTypeGroups String

    link to root ContentTypeGroups resource (should be auto-discovered)

  • contentTypeGroupCreateStruct ContentTypeGroupInputStruct

    object describing the new group to be created

  • callback Function

    callback executed after performing the request (see Note on the callbacks usage for more info)

Example:

var contentTypeGroupCreateStruct = contentTypeService.newContentTypeGroupInputStruct(
    "new-group-id"
);

contentTypeService.createContentTypeGroup(
    "/api/ezp/v2/content/typegroups",
    contentTypeGroupCreateStruct,
    callback
);

deleteContentType

(
  • contentTypeId
  • callback
)

Delete the target content type

Parameters:

  • contentTypeId String

    target content type identifier (e.g. "/api/ezp/v2/content/types/18")

  • callback Function

    callback executed after performing the request (see Note on the callbacks usage for more info)

deleteContentTypeDraft

(
  • contentTypeDraftId
  • callback
)

Delete the target content type draft

Parameters:

  • contentTypeDraftId String

    target content type draft identifier (e.g. "/api/ezp/v2/content/types/18/draft")

  • callback Function

    callback executed after performing the request (see Note on the callbacks usage for more info)

deleteContentTypeGroup

(
  • contentTypeGroupId
  • callback
)

Delete content type group

Parameters:

  • contentTypeGroupId String
  • callback Function

    callback executed after performing the request (see Note on the callbacks usage for more info)

deleteFieldDefinition

(
  • fieldDefinitionId
  • callback
)

Delete existing field definition

Parameters:

  • fieldDefinitionId String

    target field definition identifier (e.g. "/api/ezp/v2/content/types/42/fieldDefinitions/311")

  • callback Function

    callback executed after performing the request (see Note on the callbacks usage for more info)

loadContentType

(
  • contentTypeId
  • callback
)

Load the target content type

Parameters:

  • contentTypeId String

    target content type identifier (e.g. "/api/ezp/v2/content/types/18")

  • callback Function

    callback executed after performing the request (see Note on the callbacks usage for more info)

loadContentTypeByIdentifier

(
  • identifier
  • callback
)

Load content type by the string identifier

Parameters:

  • identifier String

    target content type string identifier (e.g. "blog")

  • callback Function

    callback executed after performing the request (see Note on the callbacks usage for more info)

loadContentTypeDraft

(
  • contentTypeId
  • callback
)

Load draft of the target content type

Parameters:

  • contentTypeId String

    target content type identifier (e.g. "/api/ezp/v2/content/types/18")

  • callback Function

    callback executed after performing the request (see Note on the callbacks usage for more info)

loadContentTypeGroup

(
  • contentTypeGroupId
  • callback
)

Load single content type group

Parameters:

  • contentTypeGroupId String

    target content type group identifier (e.g. "/api/ezp/v2/content/types/100")

  • callback Function

    callback executed after performing the request (see Note on the callbacks usage for more info)

loadContentTypeGroupByIdentifier

(
  • contentTypeGroups
  • identifier
  • callback
)

Parameters:

  • contentTypeGroups String

    link to root ContentTypeGroups resource (should be auto-discovered)

  • identifier String

    target content type group identifier (e.g. "content")

  • callback Function

    callback executed after performing the request (see Note on the callbacks usage for more info)

loadContentTypeGroups

(
  • callback
)

Load all content type groups

Parameters:

loadContentTypes

(
  • contentTypeGroupId
  • callback
)

List content for a content type group

Parameters:

  • contentTypeGroupId String

    target content type group identifier (e.g. "/api/ezp/v2/content/typegroups/1")

  • callback Function

    callback executed after performing the request (see Note on the callbacks usage for more info)

loadFieldDefinition

(
  • fieldDefinitionId
  • callback
)

Load the target field definition

Parameters:

  • fieldDefinitionId String

    target field definition identifier (e.g. "/api/ezp/v2/content/types/42/fieldDefinitions/311")

  • callback Function

    callback executed after performing the request (see Note on the callbacks usage for more info)

loadGroupsOfContentType

(
  • contentTypeId
  • callback
)

Load content type groups of the target content type

Parameters:

  • contentTypeId String

    target content type identifier (e.g. "/api/ezp/v2/content/types/18")

  • callback Function

    callback executed after performing the request (see Note on the callbacks usage for more info)

newContentTypeCreateStruct

(
  • identifier
  • languageCode
  • names
)
ContentTypeCreateStruct

Parameters:

  • identifier String

    unique content type identifer (e.g. "my-type")

  • languageCode String

    The language code (eng-GB, fre-FR, ...)

  • names Array

    Multi language value (see example)

Example:

 var contentTypeCreateStruct = contentTypeService.newContentTypeCreateStruct(
     "some-id", "eng-US", [{
         "_languageCode":"eng-US",
         "#text":"Some Name"
     }]
 );

newContentTypeGroupInputStruct

(
  • identifier
)
ContentTypeGroupInputStruct

Returns content type group create structure

Parameters:

  • identifier String

    unique content type group identifer (e.g. "my-group")

newFieldDefinitionCreateStruct

(
  • identifier
  • fieldType
  • fieldGroup
  • names
)
FieldDefinitionCreateStruct

Parameters:

  • identifier String

    unique field definiton identifer (e.g. "my-field")

  • fieldType String

    identifier of existing field type (e.g. "ezstring", "ezdate")

  • fieldGroup String

    identifier of existing field group (e.g. "content", "meta")

  • names Array

    Multi language value (see example)

Example:

var fieldDefinition = contentTypeService.newFieldDefinitionCreateStruct(
    "my-new-field", "ezstring", "content", [{
        "_languageCode":"eng-US",
        "#text":"Subtitle"
    }]
);

publishContentTypeDraft

(
  • contentTypeDraftId
  • callback
)

Publish the target content type draft

Parameters:

  • contentTypeDraftId String

    target content type draft identifier (e.g. "/api/ezp/v2/content/types/18/draft")

  • callback Function

    callback executed after performing the request (see Note on the callbacks usage for more info)

unassignContentTypeGroup

(
  • contentTypeAssignedGroupId
  • callback
)

Remove content type assignment to the target content type group

Parameters:

  • contentTypeAssignedGroupId String

    target content type group assignment (e.g. "/api/ezp/v2/content/types/18/groups/1")

  • callback Function

    callback executed after performing the request (see Note on the callbacks usage for more info)

updateContentTypeDraftMetadata

(
  • contentTypeDraftId
  • contentTypeUpdateStruct
  • callback
)

Update the target content type draft metadata. This method does not handle field definitions

Parameters:

  • contentTypeDraftId String

    target content type draft identifier (e.g. "/api/ezp/v2/content/types/18/draft")

  • contentTypeUpdateStruct ContentTypeUpdateStruct

    object describing changes to the draft

  • callback Function

    callback executed after performing the request (see Note on the callbacks usage for more info)

updateContentTypeGroup

(
  • contentTypeGroupId
  • contentTypeGroupUpdateStruct
  • callback
)

Update a content type group

Parameters:

  • contentTypeGroupId String

    target content type group identifier (e.g. "/api/ezp/v2/content/types/100")

  • contentTypeGroupUpdateStruct ContentTypeGroupInputStruct

    object describing changes to the content type group

  • callback Function

    callback executed after performing the request (see Note on the callbacks usage for more info)

updateFieldDefinition

(
  • fieldDefinitionId
  • fieldDefinitionUpdateStruct
  • callback
)

Update the target (existing) field definition

Parameters:

  • fieldDefinitionId String

    target field definition identifier (e.g. "/api/ezp/v2/content/types/42/fieldDefinitions/311")

  • fieldDefinitionUpdateStruct FieldDefinitionUpdateStruct

    object describing changes to the target field definition

  • callback Function

    callback executed after performing the request (see Note on the callbacks usage for more info)