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:
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
ConnectionManagerconnection manager that will be used to send requests to REST service
-
discoveryService
DiscoveryServicediscovery service is used for urls auto-discovery automation
Example:
var contentTypeService = jsCAPI.getContentTypeService();
Item Index
Methods
- addFieldDefinition
- assignContentTypeGroup
- copyContentType
- createContentType
- createContentTypeDraft
- createContentTypeGroup
- deleteContentType
- deleteContentTypeDraft
- deleteContentTypeGroup
- deleteFieldDefinition
- loadContentType
- loadContentTypeByIdentifier
- loadContentTypeDraft
- loadContentTypeGroup
- loadContentTypeGroupByIdentifier
- loadContentTypeGroups
- loadContentTypes
- loadFieldDefinition
- loadGroupsOfContentType
- newContentTypeCreateStruct
- newContentTypeGroupInputStruct
- newContentTypeUpdateStruct
- newFieldDefinitionCreateStruct
- newFieldDefinitionUpdateStruct
- publishContentTypeDraft
- unassignContentTypeGroup
- updateContentTypeDraftMetadata
- updateContentTypeGroup
- updateFieldDefinition
Methods
addFieldDefinition
-
contentTypeId
-
fieldDefinitionCreateStruct
-
callback
Add a new field definition to the target Content Type draft
Parameters:
-
contentTypeId
Stringtarget content type identifier (e.g. "/api/ezp/v2/content/types/18")
-
fieldDefinitionCreateStruct
FieldDefinitionCreateStructobject describing the new field definition to be created
-
callback
Functioncallback 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
Stringtarget content type identifier (e.g. "/api/ezp/v2/content/types/18")
-
groupId
Stringtarget content type group identifier (e.g. "/api/ezp/v2/content/typegroups/2")
-
callback
Functioncallback 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
Stringtarget content type identifier (e.g. "/api/ezp/v2/content/types/18")
-
callback
Functioncallback 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
Stringtarget content type group identifier (e.g. "/api/ezp/v2/content/typegroups/1")
-
contentTypeCreateStruct
ContentTypeCreateStructobject describing the new content type to be created
-
publish
Booleanweather the content type should be immediately published or not
-
callback
Functioncallback 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
Stringtarget content type identifier (e.g. "/api/ezp/v2/content/types/18")
-
contentTypeUpdateStruct
ContentTypeUpdateStructobject describing changes to the content type
-
callback
Functioncallback 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
Stringlink to root ContentTypeGroups resource (should be auto-discovered)
-
contentTypeGroupCreateStruct
ContentTypeGroupInputStructobject describing the new group to be created
-
callback
Functioncallback 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
Stringtarget content type identifier (e.g. "/api/ezp/v2/content/types/18")
-
callback
Functioncallback 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
Stringtarget content type draft identifier (e.g. "/api/ezp/v2/content/types/18/draft")
-
callback
Functioncallback 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
Functioncallback executed after performing the request (see Note on the callbacks usage for more info)
deleteFieldDefinition
-
fieldDefinitionId
-
callback
Delete existing field definition
Parameters:
-
fieldDefinitionId
Stringtarget field definition identifier (e.g. "/api/ezp/v2/content/types/42/fieldDefinitions/311")
-
callback
Functioncallback executed after performing the request (see Note on the callbacks usage for more info)
loadContentType
-
contentTypeId
-
callback
Load the target content type
Parameters:
-
contentTypeId
Stringtarget content type identifier (e.g. "/api/ezp/v2/content/types/18")
-
callback
Functioncallback 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
Stringtarget content type string identifier (e.g. "blog")
-
callback
Functioncallback 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
Stringtarget content type identifier (e.g. "/api/ezp/v2/content/types/18")
-
callback
Functioncallback executed after performing the request (see Note on the callbacks usage for more info)
loadContentTypeGroup
-
contentTypeGroupId
-
callback
Load single content type group
Parameters:
-
contentTypeGroupId
Stringtarget content type group identifier (e.g. "/api/ezp/v2/content/types/100")
-
callback
Functioncallback executed after performing the request (see Note on the callbacks usage for more info)
loadContentTypeGroupByIdentifier
-
contentTypeGroups
-
identifier
-
callback
Parameters:
-
contentTypeGroups
Stringlink to root ContentTypeGroups resource (should be auto-discovered)
-
identifier
Stringtarget content type group identifier (e.g. "content")
-
callback
Functioncallback executed after performing the request (see Note on the callbacks usage for more info)
loadContentTypeGroups
-
callback
Load all content type groups
Parameters:
-
callback
Functioncallback executed after performing the request (see Note on the callbacks usage for more info)
loadContentTypes
-
contentTypeGroupId
-
callback
List content for a content type group
Parameters:
-
contentTypeGroupId
Stringtarget content type group identifier (e.g. "/api/ezp/v2/content/typegroups/1")
-
callback
Functioncallback executed after performing the request (see Note on the callbacks usage for more info)
loadFieldDefinition
-
fieldDefinitionId
-
callback
Load the target field definition
Parameters:
-
fieldDefinitionId
Stringtarget field definition identifier (e.g. "/api/ezp/v2/content/types/42/fieldDefinitions/311")
-
callback
Functioncallback 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
Stringtarget content type identifier (e.g. "/api/ezp/v2/content/types/18")
-
callback
Functioncallback executed after performing the request (see Note on the callbacks usage for more info)
newContentTypeCreateStruct
-
identifier
-
languageCode
-
names
Parameters:
-
identifier
Stringunique content type identifer (e.g. "my-type")
-
languageCode
StringThe language code (eng-GB, fre-FR, ...)
-
names
ArrayMulti language value (see example)
Returns:
Example:
var contentTypeCreateStruct = contentTypeService.newContentTypeCreateStruct(
"some-id", "eng-US", [{
"_languageCode":"eng-US",
"#text":"Some Name"
}]
);
newContentTypeGroupInputStruct
-
identifier
Returns content type group create structure
Parameters:
-
identifier
Stringunique content type group identifer (e.g. "my-group")
Returns:
newFieldDefinitionCreateStruct
-
identifier
-
fieldType
-
fieldGroup
-
names
Parameters:
-
identifier
Stringunique field definiton identifer (e.g. "my-field")
-
fieldType
Stringidentifier of existing field type (e.g. "ezstring", "ezdate")
-
fieldGroup
Stringidentifier of existing field group (e.g. "content", "meta")
-
names
ArrayMulti language value (see example)
Returns:
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
Stringtarget content type draft identifier (e.g. "/api/ezp/v2/content/types/18/draft")
-
callback
Functioncallback 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
Stringtarget content type group assignment (e.g. "/api/ezp/v2/content/types/18/groups/1")
-
callback
Functioncallback 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
Stringtarget content type draft identifier (e.g. "/api/ezp/v2/content/types/18/draft")
-
contentTypeUpdateStruct
ContentTypeUpdateStructobject describing changes to the draft
-
callback
Functioncallback 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
Stringtarget content type group identifier (e.g. "/api/ezp/v2/content/types/100")
-
contentTypeGroupUpdateStruct
ContentTypeGroupInputStructobject describing changes to the content type group
-
callback
Functioncallback 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
Stringtarget field definition identifier (e.g. "/api/ezp/v2/content/types/42/fieldDefinitions/311")
-
fieldDefinitionUpdateStruct
FieldDefinitionUpdateStructobject describing changes to the target field definition
-
callback
Functioncallback executed after performing the request (see Note on the callbacks usage for more info)