Content Service
Example on how to create and publish content programmatically using the ContentService.
Learn how to use the Content Service.
Creating content programmatically
In the example below, a new page is programmatically created using the content service. It is assumed that there are two document types, namely Catalogue and Product. In this case, a new Product is added underneath the Catalogue page. Add the below code in the Catalogue template.
In a multi-language setup, it is necessary to set the name of the content item for a specified culture:
For information on how to retrieve multilingual languages, see the Retrieving languages article.
Publishing content programmatically
The ContentService is also used for publishing operations.
The following example shows a page being published with all descendants.
The PublishBranchFilter
option can include one or more of the following flags:
Default
- publishes existing published content with pending changes.IncludeUnpublished
- publishes unpublished content and existing published with pending changes.ForceRepublish
- publishes existing published content with or without pending changes.All
- combinesIncludeUnpublished
andForceRepublish
.
Last updated
Was this helpful?