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:
-
connectionManagerConnectionManagerconnection manager that will be used to send requests to REST service
-
discoveryServiceDiscoveryServicediscovery 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:
-
contentTypeIdStringtarget content type identifier (e.g. "/api/ezp/v2/content/types/18")
-
fieldDefinitionCreateStructFieldDefinitionCreateStructobject describing the new field definition to be created
-
callbackFunctioncallback 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:
-
contentTypeIdStringtarget content type identifier (e.g. "/api/ezp/v2/content/types/18")
-
groupIdStringtarget content type group identifier (e.g. "/api/ezp/v2/content/typegroups/2")
-
callbackFunctioncallback 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:
-
contentTypeIdStringtarget content type identifier (e.g. "/api/ezp/v2/content/types/18")
-
callbackFunctioncallback executed after performing the request (see Note on the callbacks usage for more info)
createContentType
-
contentTypeGroupId -
contentTypeCreateStruct -
publish -
callback
Create a content type
Parameters:
-
contentTypeGroupIdStringtarget content type group identifier (e.g. "/api/ezp/v2/content/typegroups/1")
-
contentTypeCreateStructContentTypeCreateStructobject describing the new content type to be created
-
publishBooleanweather the content type should be immediately published or not
-
callbackFunctioncallback 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:
-
contentTypeIdStringtarget content type identifier (e.g. "/api/ezp/v2/content/types/18")
-
contentTypeUpdateStructContentTypeUpdateStructobject describing changes to the content type
-
callbackFunctioncallback 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:
-
contentTypeGroupsStringlink to root ContentTypeGroups resource (should be auto-discovered)
-
contentTypeGroupCreateStructContentTypeGroupInputStructobject describing the new group to be created
-
callbackFunctioncallback 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:
-
contentTypeIdStringtarget content type identifier (e.g. "/api/ezp/v2/content/types/18")
-
callbackFunctioncallback executed after performing the request (see Note on the callbacks usage for more info)
deleteContentTypeDraft
-
contentTypeDraftId -
callback
Delete the target content type draft
Parameters:
-
contentTypeDraftIdStringtarget content type draft identifier (e.g. "/api/ezp/v2/content/types/18/draft")
-
callbackFunctioncallback executed after performing the request (see Note on the callbacks usage for more info)
deleteContentTypeGroup
-
contentTypeGroupId -
callback
Delete content type group
Parameters:
-
contentTypeGroupIdString -
callbackFunctioncallback executed after performing the request (see Note on the callbacks usage for more info)
deleteFieldDefinition
-
fieldDefinitionId -
callback
Delete existing field definition
Parameters:
-
fieldDefinitionIdStringtarget field definition identifier (e.g. "/api/ezp/v2/content/types/42/fieldDefinitions/311")
-
callbackFunctioncallback executed after performing the request (see Note on the callbacks usage for more info)
loadContentType
-
contentTypeId -
callback
Load the target content type
Parameters:
-
contentTypeIdStringtarget content type identifier (e.g. "/api/ezp/v2/content/types/18")
-
callbackFunctioncallback 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:
-
identifierStringtarget content type string identifier (e.g. "blog")
-
callbackFunctioncallback 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:
-
contentTypeIdStringtarget content type identifier (e.g. "/api/ezp/v2/content/types/18")
-
callbackFunctioncallback executed after performing the request (see Note on the callbacks usage for more info)
loadContentTypeGroup
-
contentTypeGroupId -
callback
Load single content type group
Parameters:
-
contentTypeGroupIdStringtarget content type group identifier (e.g. "/api/ezp/v2/content/types/100")
-
callbackFunctioncallback executed after performing the request (see Note on the callbacks usage for more info)
loadContentTypeGroupByIdentifier
-
contentTypeGroups -
identifier -
callback
Parameters:
-
contentTypeGroupsStringlink to root ContentTypeGroups resource (should be auto-discovered)
-
identifierStringtarget content type group identifier (e.g. "content")
-
callbackFunctioncallback executed after performing the request (see Note on the callbacks usage for more info)
loadContentTypeGroups
-
callback
Load all content type groups
Parameters:
-
callbackFunctioncallback 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:
-
contentTypeGroupIdStringtarget content type group identifier (e.g. "/api/ezp/v2/content/typegroups/1")
-
callbackFunctioncallback executed after performing the request (see Note on the callbacks usage for more info)
loadFieldDefinition
-
fieldDefinitionId -
callback
Load the target field definition
Parameters:
-
fieldDefinitionIdStringtarget field definition identifier (e.g. "/api/ezp/v2/content/types/42/fieldDefinitions/311")
-
callbackFunctioncallback 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:
-
contentTypeIdStringtarget content type identifier (e.g. "/api/ezp/v2/content/types/18")
-
callbackFunctioncallback executed after performing the request (see Note on the callbacks usage for more info)
newContentTypeCreateStruct
-
identifier -
languageCode -
names
Parameters:
-
identifierStringunique content type identifer (e.g. "my-type")
-
languageCodeStringThe language code (eng-GB, fre-FR, ...)
-
namesArrayMulti 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:
-
identifierStringunique content type group identifer (e.g. "my-group")
Returns:
newFieldDefinitionCreateStruct
-
identifier -
fieldType -
fieldGroup -
names
Parameters:
-
identifierStringunique field definiton identifer (e.g. "my-field")
-
fieldTypeStringidentifier of existing field type (e.g. "ezstring", "ezdate")
-
fieldGroupStringidentifier of existing field group (e.g. "content", "meta")
-
namesArrayMulti 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:
-
contentTypeDraftIdStringtarget content type draft identifier (e.g. "/api/ezp/v2/content/types/18/draft")
-
callbackFunctioncallback 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:
-
contentTypeAssignedGroupIdStringtarget content type group assignment (e.g. "/api/ezp/v2/content/types/18/groups/1")
-
callbackFunctioncallback 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:
-
contentTypeDraftIdStringtarget content type draft identifier (e.g. "/api/ezp/v2/content/types/18/draft")
-
contentTypeUpdateStructContentTypeUpdateStructobject describing changes to the draft
-
callbackFunctioncallback executed after performing the request (see Note on the callbacks usage for more info)
updateContentTypeGroup
-
contentTypeGroupId -
contentTypeGroupUpdateStruct -
callback
Update a content type group
Parameters:
-
contentTypeGroupIdStringtarget content type group identifier (e.g. "/api/ezp/v2/content/types/100")
-
contentTypeGroupUpdateStructContentTypeGroupInputStructobject describing changes to the content type group
-
callbackFunctioncallback 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:
-
fieldDefinitionIdStringtarget field definition identifier (e.g. "/api/ezp/v2/content/types/42/fieldDefinitions/311")
-
fieldDefinitionUpdateStructFieldDefinitionUpdateStructobject describing changes to the target field definition
-
callbackFunctioncallback executed after performing the request (see Note on the callbacks usage for more info)
