Interface IContentService
Defines the ContentService, which is an easy access to operations involving IContent
Namespace: Umbraco.Cms.Core.Services
Assembly: Umbraco.Core.dll
Syntax
public interface IContentService : IContentServiceBase<IContent>, IContentServiceBase, IService
Methods
View SourceCopy(IContent, int, bool, bool, int)
Copies a document.
Declaration
IContent? Copy(IContent content, int parentId, bool relateToOriginal, bool recursive, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | content | The document to copy. |
| int | parentId | The identifier of the new parent. |
| bool | relateToOriginal | Whether to relate the copy to the original. |
| bool | recursive | Whether to recursively copy all children. |
| int | userId | The identifier of the user performing the action. |
Returns
| Type | Description |
|---|---|
| IContent | The copied document, or null if the copy failed. |
Remarks
Optionally recursively copies all children.
Copy(IContent, int, bool, int)
Copies a document.
Declaration
IContent? Copy(IContent content, int parentId, bool relateToOriginal, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | content | The document to copy. |
| int | parentId | The identifier of the new parent. |
| bool | relateToOriginal | Whether to relate the copy to the original. |
| int | userId | The identifier of the user performing the action. |
Returns
| Type | Description |
|---|---|
| IContent | The copied document, or null if the copy failed. |
Remarks
Recursively copies all children.
Count(string?)
Counts documents of a given document type.
Declaration
int Count(string? documentTypeAlias = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | documentTypeAlias | The document type alias, or null for all types. |
Returns
| Type | Description |
|---|---|
| int | The document count. |
CountChildren(int, string?)
Counts child documents of a given parent, of a given document type.
Declaration
int CountChildren(int parentId, string? documentTypeAlias = null)
Parameters
| Type | Name | Description |
|---|---|---|
| int | parentId | The parent identifier. |
| string | documentTypeAlias | The document type alias, or null for all types. |
Returns
| Type | Description |
|---|---|
| int | The child document count. |
CountDescendants(int, string?)
Counts descendant documents of a given parent, of a given document type.
Declaration
int CountDescendants(int parentId, string? documentTypeAlias = null)
Parameters
| Type | Name | Description |
|---|---|---|
| int | parentId | The parent identifier. |
| string | documentTypeAlias | The document type alias, or null for all types. |
Returns
| Type | Description |
|---|---|
| int | The descendant document count. |
CountPublished(string?)
Counts published documents of a given document type.
Declaration
int CountPublished(string? documentTypeAlias = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | documentTypeAlias | The document type alias, or null for all types. |
Returns
| Type | Description |
|---|---|
| int | The published document count. |
Create(string, Guid, string, int)
Creates a document.
Declaration
IContent Create(string name, Guid parentId, string documentTypeAlias, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the document. |
| Guid | parentId | The unique identifier of the parent. |
| string | documentTypeAlias | The document type alias. |
| int | userId | The identifier of the user performing the action. |
Returns
| Type | Description |
|---|---|
| IContent | The created document. |
Create(string, int, string, int)
Creates a document.
Declaration
IContent Create(string name, int parentId, string documentTypeAlias, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the document. |
| int | parentId | The identifier of the parent. |
| string | documentTypeAlias | The document type alias. |
| int | userId | The identifier of the user performing the action. |
Returns
| Type | Description |
|---|---|
| IContent | The created document. |
Create(string, int, IContentType, int)
Creates a document.
Declaration
IContent Create(string name, int parentId, IContentType contentType, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the document. |
| int | parentId | The identifier of the parent. |
| IContentType | contentType | The content type. |
| int | userId | The identifier of the user performing the action. |
Returns
| Type | Description |
|---|---|
| IContent | The created document. |
Create(string, IContent?, string, int)
Creates a document.
Declaration
IContent Create(string name, IContent? parent, string documentTypeAlias, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the document. |
| IContent | parent | The parent document. |
| string | documentTypeAlias | The document type alias. |
| int | userId | The identifier of the user performing the action. |
Returns
| Type | Description |
|---|---|
| IContent | The created document. |
CreateAndSave(string, int, string, int)
Creates and saves a document.
Declaration
IContent CreateAndSave(string name, int parentId, string contentTypeAlias, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the document. |
| int | parentId | The identifier of the parent. |
| string | contentTypeAlias | The content type alias. |
| int | userId | The identifier of the user performing the action. |
Returns
| Type | Description |
|---|---|
| IContent | The created and saved document. |
CreateAndSave(string, IContent, string, int)
Creates and saves a document.
Declaration
IContent CreateAndSave(string name, IContent parent, string contentTypeAlias, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the document. |
| IContent | parent | The parent document. |
| string | contentTypeAlias | The content type alias. |
| int | userId | The identifier of the user performing the action. |
Returns
| Type | Description |
|---|---|
| IContent | The created and saved document. |
CreateBlueprintFromContent(IContent, string, int)
Creates a blueprint from a content item.
Declaration
IContent CreateBlueprintFromContent(IContent blueprint, string name, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | blueprint | The content item to create a blueprint from. |
| string | name | The name for the new blueprint. |
| int | userId | The identifier of the user performing the action. |
Returns
| Type | Description |
|---|---|
| IContent | The created blueprint. |
CreateContentFromBlueprint(IContent, string, int)
(Deprecated) Creates a new content item from a blueprint.
Declaration
[Obsolete("Use IContentBlueprintEditingService.GetScaffoldedAsync() instead. Scheduled for removal in Umbraco 18.")]
IContent CreateContentFromBlueprint(IContent blueprint, string name, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | blueprint | The blueprint to create content from. |
| string | name | The name for the new content. |
| int | userId | The identifier of the user performing the action. |
Returns
| Type | Description |
|---|---|
| IContent | The created content. |
Remarks
If creating content from a blueprint, use GetScaffoldedAsync(Guid) instead. If creating a blueprint from content use CreateBlueprintFromContent(IContent, string, int) instead.
Delete(IContent, int)
Deletes a document.
Declaration
OperationResult Delete(IContent content, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | content | The document to delete. |
| int | userId | The identifier of the user performing the action. |
Returns
| Type | Description |
|---|---|
| OperationResult | The operation result. |
Remarks
This method will also delete associated media files, child content and possibly associated domains.
This method entirely clears the content from the database.
DeleteBlueprint(IContent, int)
Deletes a blueprint.
Declaration
void DeleteBlueprint(IContent content, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | content | The blueprint to delete. |
| int | userId | The identifier of the user performing the action. |
DeleteBlueprintsOfType(int, int)
Deletes blueprints for a content type.
Declaration
void DeleteBlueprintsOfType(int contentTypeId, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| int | contentTypeId | The content type identifier. |
| int | userId | The identifier of the user performing the action. |
DeleteBlueprintsOfTypes(IEnumerable<int>, int)
Deletes blueprints for content types.
Declaration
void DeleteBlueprintsOfTypes(IEnumerable<int> contentTypeIds, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<int> | contentTypeIds | The content type identifiers. |
| int | userId | The identifier of the user performing the action. |
DeleteOfType(int, int)
Deletes all documents of a given document type.
Declaration
void DeleteOfType(int documentTypeId, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| int | documentTypeId | The document type identifier. |
| int | userId | The identifier of the user performing the action. |
Remarks
All non-deleted descendants of the deleted documents are moved to the recycle bin.
This operation is potentially dangerous and expensive.
DeleteOfTypes(IEnumerable<int>, int)
Deletes all documents of given document types.
Declaration
void DeleteOfTypes(IEnumerable<int> contentTypeIds, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<int> | contentTypeIds | The content type identifiers. |
| int | userId | The identifier of the user performing the action. |
Remarks
All non-deleted descendants of the deleted documents are moved to the recycle bin.
This operation is potentially dangerous and expensive.
DeleteVersion(int, int, bool, int)
Deletes a version of a document.
Declaration
void DeleteVersion(int id, int versionId, bool deletePriorVersions, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | The document identifier. |
| int | versionId | The version identifier to delete. |
| bool | deletePriorVersions | Whether to also delete versions prior to the specified version. |
| int | userId | The identifier of the user performing the action. |
DeleteVersions(int, DateTime, int)
Deletes versions of a document prior to a given date.
Declaration
void DeleteVersions(int id, DateTime date, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | The document identifier. |
| DateTime | date | The date before which versions should be deleted. |
| int | userId | The identifier of the user performing the action. |
EmptyRecycleBin(int)
Empties the Recycle Bin by deleting all IContent that resides in the bin.
Declaration
OperationResult EmptyRecycleBin(int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| int | userId | Optional identifier of the user emptying the Recycle Bin. |
Returns
| Type | Description |
|---|---|
| OperationResult | The operation result. |
EmptyRecycleBinAsync(Guid)
Empties the Recycle Bin asynchronously by deleting all IContent that resides in the bin.
Declaration
Task<OperationResult> EmptyRecycleBinAsync(Guid userId)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | userId | The unique identifier of the user emptying the Recycle Bin. |
Returns
| Type | Description |
|---|---|
| Task<OperationResult> | A task representing the asynchronous operation with the operation result. |
GetAncestors(int)
Gets ancestor documents of a document.
Declaration
IEnumerable<IContent> GetAncestors(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | The identifier of the document. |
Returns
| Type | Description |
|---|---|
| IEnumerable<IContent> | The ancestor documents. |
GetAncestors(IContent)
Gets ancestor documents of a document.
Declaration
IEnumerable<IContent> GetAncestors(IContent content)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | content | The document. |
Returns
| Type | Description |
|---|---|
| IEnumerable<IContent> | The ancestor documents. |
GetBlueprintById(Guid)
Gets a blueprint.
Declaration
IContent? GetBlueprintById(Guid id)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | id | The unique identifier of the blueprint. |
Returns
| Type | Description |
|---|---|
| IContent | The blueprint, or null if not found. |
GetBlueprintById(int)
Gets a blueprint.
Declaration
IContent? GetBlueprintById(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | The identifier of the blueprint. |
Returns
| Type | Description |
|---|---|
| IContent | The blueprint, or null if not found. |
GetBlueprintsForContentTypes(params int[])
Gets blueprints for a content type.
Declaration
IEnumerable<IContent> GetBlueprintsForContentTypes(params int[] documentTypeId)
Parameters
| Type | Name | Description |
|---|---|---|
| int[] | documentTypeId | The document type identifiers. |
Returns
| Type | Description |
|---|---|
| IEnumerable<IContent> | The blueprints. |
GetById(Guid)
Gets a document.
Declaration
IContent? GetById(Guid key)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | key | The unique identifier of the document. |
Returns
| Type | Description |
|---|---|
| IContent | The document, or null if not found. |
GetById(int)
Gets a document.
Declaration
IContent? GetById(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | The identifier of the document. |
Returns
| Type | Description |
|---|---|
| IContent | The document, or null if not found. |
GetByIds(IEnumerable<Guid>)
Gets documents.
Declaration
IEnumerable<IContent> GetByIds(IEnumerable<Guid> ids)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<Guid> | ids | The unique identifiers of the documents. |
Returns
| Type | Description |
|---|---|
| IEnumerable<IContent> | The documents. |
GetByIds(IEnumerable<int>)
Gets documents.
Declaration
IEnumerable<IContent> GetByIds(IEnumerable<int> ids)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<int> | ids | The identifiers of the documents. |
Returns
| Type | Description |
|---|---|
| IEnumerable<IContent> | The documents. |
GetByLevel(int)
Gets documents at a given level.
Declaration
IEnumerable<IContent> GetByLevel(int level)
Parameters
| Type | Name | Description |
|---|---|---|
| int | level | The level. |
Returns
| Type | Description |
|---|---|
| IEnumerable<IContent> | The documents at the specified level. |
GetContentForExpiration(DateTime)
Gets documents having an expiration date before (lower than, or equal to) a specified date.
Declaration
IEnumerable<IContent> GetContentForExpiration(DateTime date)
Parameters
| Type | Name | Description |
|---|---|---|
| DateTime | date |
Returns
| Type | Description |
|---|---|
| IEnumerable<IContent> | An Enumerable list of IContent objects |
Remarks
The content returned from this method may be culture variant, in which case you can use GetStatus(IContent, ContentScheduleCollection, string?) to get the status for a specific culture.
GetContentForRelease(DateTime)
Gets documents having a release date before (lower than, or equal to) a specified date.
Declaration
IEnumerable<IContent> GetContentForRelease(DateTime date)
Parameters
| Type | Name | Description |
|---|---|---|
| DateTime | date |
Returns
| Type | Description |
|---|---|
| IEnumerable<IContent> | An Enumerable list of IContent objects |
Remarks
The content returned from this method may be culture variant, in which case you can use GetStatus(IContent, ContentScheduleCollection, string?) to get the status for a specific culture.
GetContentScheduleByContentId(Guid)
Gets publish/unpublish schedule for a content node.
Declaration
ContentScheduleCollection GetContentScheduleByContentId(Guid contentId)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | contentId | The unique identifier of the content to load schedule for. |
Returns
| Type | Description |
|---|---|
| ContentScheduleCollection |
GetContentScheduleByContentId(int)
Gets publish/unpublish schedule for a content node.
Declaration
ContentScheduleCollection GetContentScheduleByContentId(int contentId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | contentId | The identifier of the content to load schedule for. |
Returns
| Type | Description |
|---|---|
| ContentScheduleCollection |
GetContentSchedulesByIds(Guid[])
Gets a dictionary of content Ids and their matching content schedules.
Declaration
[Obsolete("Use GetContentSchedulesByKeys instead. Scheduled for removal in Umbraco 19.")]
IDictionary<int, IEnumerable<ContentSchedule>> GetContentSchedulesByIds(Guid[] keys)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid[] | keys | The content keys. |
Returns
| Type | Description |
|---|---|
| IDictionary<int, IEnumerable<ContentSchedule>> | A dictionary with a node Id and an IEnumerable of matching ContentSchedules. |
GetContentSchedulesByKeys(Guid[])
Gets a dictionary of content keys and their matching content schedules.
Declaration
IDictionary<Guid, IEnumerable<ContentSchedule>> GetContentSchedulesByKeys(Guid[] keys)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid[] | keys | The content keys. |
Returns
| Type | Description |
|---|---|
| IDictionary<Guid, IEnumerable<ContentSchedule>> | A dictionary with a content key and an IEnumerable of matching ContentSchedules. |
GetPagedChildren(int, long, int, out long, string[]?, IQuery<IContent>?, Ordering?, bool)
Gets child documents of a parent with optional property filtering.
Declaration
IEnumerable<IContent> GetPagedChildren(int id, long pageIndex, int pageSize, out long totalRecords, string[]? propertyAliases, IQuery<IContent>? filter, Ordering? ordering, bool loadTemplates = true)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | The parent identifier. |
| long | pageIndex | The page number. |
| int | pageSize | The page size. |
| long | totalRecords | Total number of documents. |
| string[] | propertyAliases | The property aliases to load. If null, all properties are loaded. If empty array, no custom properties are loaded. |
| IQuery<IContent> | filter | Query filter. |
| Ordering | ordering | Ordering infos. |
| bool | loadTemplates | Whether to load templates. Set to false for performance optimization when templates are not needed (e.g., collection views). Default is true. |
Returns
| Type | Description |
|---|---|
| IEnumerable<IContent> |
GetPagedChildren(int, long, int, out long, IQuery<IContent>?, Ordering?)
Gets child documents of a parent.
Declaration
[Obsolete("Please use the method overload with all parameters. Scheduled for removal in Umbraco 19.")]
IEnumerable<IContent> GetPagedChildren(int id, long pageIndex, int pageSize, out long totalRecords, IQuery<IContent>? filter = null, Ordering? ordering = null)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | The parent identifier. |
| long | pageIndex | The page number. |
| int | pageSize | The page size. |
| long | totalRecords | Total number of documents. |
| IQuery<IContent> | filter | Query filter. |
| Ordering | ordering | Ordering infos. |
Returns
| Type | Description |
|---|---|
| IEnumerable<IContent> |
GetPagedContentInRecycleBin(long, int, out long, IQuery<IContent>?, Ordering?)
Gets documents in the recycle bin.
Declaration
IEnumerable<IContent> GetPagedContentInRecycleBin(long pageIndex, int pageSize, out long totalRecords, IQuery<IContent>? filter = null, Ordering? ordering = null)
Parameters
| Type | Name | Description |
|---|---|---|
| long | pageIndex | |
| int | pageSize | |
| long | totalRecords | |
| IQuery<IContent> | filter | |
| Ordering | ordering |
Returns
| Type | Description |
|---|---|
| IEnumerable<IContent> |
GetPagedDescendants(int, long, int, out long, IQuery<IContent>?, Ordering?)
Gets descendant documents of a given parent.
Declaration
IEnumerable<IContent> GetPagedDescendants(int id, long pageIndex, int pageSize, out long totalRecords, IQuery<IContent>? filter = null, Ordering? ordering = null)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | The parent identifier. |
| long | pageIndex | The page number. |
| int | pageSize | The page size. |
| long | totalRecords | Total number of documents. |
| IQuery<IContent> | filter | Query filter. |
| Ordering | ordering | Ordering infos. |
Returns
| Type | Description |
|---|---|
| IEnumerable<IContent> |
GetPagedOfType(int, long, int, out long, IQuery<IContent>, Ordering?)
Gets paged documents of a content type.
Declaration
IEnumerable<IContent> GetPagedOfType(int contentTypeId, long pageIndex, int pageSize, out long totalRecords, IQuery<IContent> filter, Ordering? ordering = null)
Parameters
| Type | Name | Description |
|---|---|---|
| int | contentTypeId | The content type identifier. |
| long | pageIndex | The page number. |
| int | pageSize | The page size. |
| long | totalRecords | Total number of documents. |
| IQuery<IContent> | filter | Query filter. |
| Ordering | ordering | Ordering infos. |
Returns
| Type | Description |
|---|---|
| IEnumerable<IContent> | The paged documents. |
GetPagedOfTypes(int[], long, int, out long, IQuery<IContent>?, Ordering?)
Gets paged documents for specified content types.
Declaration
IEnumerable<IContent> GetPagedOfTypes(int[] contentTypeIds, long pageIndex, int pageSize, out long totalRecords, IQuery<IContent>? filter, Ordering? ordering = null)
Parameters
| Type | Name | Description |
|---|---|---|
| int[] | contentTypeIds | The content type identifiers. |
| long | pageIndex | The page number. |
| int | pageSize | The page size. |
| long | totalRecords | Total number of documents. |
| IQuery<IContent> | filter | Query filter. |
| Ordering | ordering | Ordering infos. |
Returns
| Type | Description |
|---|---|
| IEnumerable<IContent> | The paged documents. |
GetParent(int)
Gets the parent of a document.
Declaration
IContent? GetParent(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | The identifier of the document. |
Returns
| Type | Description |
|---|---|
| IContent | The parent document, or null if not found. |
GetParent(IContent)
Gets the parent of a document.
Declaration
IContent? GetParent(IContent content)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | content | The document. |
Returns
| Type | Description |
|---|---|
| IContent | The parent document, or null if not found. |
GetPermissions(IContent)
Gets permissions assigned to a document.
Declaration
EntityPermissionCollection GetPermissions(IContent content)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | content | The document. |
Returns
| Type | Description |
|---|---|
| EntityPermissionCollection | The permissions assigned to the document. |
GetRootContent()
Gets root-level documents.
Declaration
IEnumerable<IContent> GetRootContent()
Returns
| Type | Description |
|---|---|
| IEnumerable<IContent> | The root-level documents. |
GetVersion(int)
Gets a version of a document.
Declaration
IContent? GetVersion(int versionId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | versionId | The version identifier. |
Returns
| Type | Description |
|---|---|
| IContent | The document version, or null if not found. |
GetVersionIds(int, int)
Gets top versions of a document.
Declaration
IEnumerable<int> GetVersionIds(int id, int topRows)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | The identifier of the document. |
| int | topRows | The number of top versions to get. |
Returns
| Type | Description |
|---|---|
| IEnumerable<int> | The version identifiers. |
Remarks
Versions are ordered with current first, then most recent first.
GetVersions(int)
Gets all versions of a document.
Declaration
IEnumerable<IContent> GetVersions(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | The identifier of the document. |
Returns
| Type | Description |
|---|---|
| IEnumerable<IContent> | The document versions. |
Remarks
Versions are ordered with current first, then most recent first.
GetVersionsSlim(int, int, int)
Gets all versions of a document.
Declaration
IEnumerable<IContent> GetVersionsSlim(int id, int skip, int take)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | The identifier of the document. |
| int | skip | The number of versions to skip. |
| int | take | The number of versions to take. |
Returns
| Type | Description |
|---|---|
| IEnumerable<IContent> | The document versions. |
Remarks
Versions are ordered with current first, then most recent first.
HasChildren(int)
Gets a value indicating whether a document has children.
Declaration
bool HasChildren(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | The document identifier. |
Returns
| Type | Description |
|---|---|
| bool |
|
IsPathPublishable(IContent)
Gets a value indicating whether a document is path-publishable.
Declaration
bool IsPathPublishable(IContent content)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | content | The document. |
Returns
| Type | Description |
|---|---|
| bool |
|
Remarks
A document is path-publishable when all its ancestors are published.
IsPathPublished(IContent)
Gets a value indicating whether a document is path-published.
Declaration
bool IsPathPublished(IContent content)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | content | The document. |
Returns
| Type | Description |
|---|---|
| bool |
|
Remarks
A document is path-published when all its ancestors, and the document itself, are published.
Move(IContent, int, bool, int)
Moves a document under a new parent, optionally leaving its descendants behind.
Declaration
OperationResult Move(IContent content, int parentId, bool includeDescendants, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | content | The document to move. |
| int | parentId | The identifier of the new parent. |
| bool | includeDescendants | Whether to move the descendants of the document along with it. When restoring a document out of the recycle
bin this can be set to |
| int | userId | The identifier of the user performing the action. |
Returns
| Type | Description |
|---|---|
| OperationResult | The operation result. |
Move(IContent, int, int)
Moves a document under a new parent.
Declaration
OperationResult Move(IContent content, int parentId, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | content | The document to move. |
| int | parentId | The identifier of the new parent. |
| int | userId | The identifier of the user performing the action. |
Returns
| Type | Description |
|---|---|
| OperationResult | The operation result. |
MoveBlueprint(IContent, int)
Moves a blueprint.
Declaration
void MoveBlueprint(IContent content, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | content | The blueprint to move. |
| int | userId | The identifier of the user performing the action. |
MoveToRecycleBin(IContent, int)
Moves a document to the recycle bin.
Declaration
OperationResult MoveToRecycleBin(IContent content, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | content | The document to move to the recycle bin. |
| int | userId | The identifier of the user performing the action. |
Returns
| Type | Description |
|---|---|
| OperationResult | The operation result. |
PerformScheduledPublish(DateTime)
Publishes and unpublishes scheduled documents.
Declaration
IEnumerable<PublishResult> PerformScheduledPublish(DateTime date)
Parameters
| Type | Name | Description |
|---|---|---|
| DateTime | date | The date to use for determining scheduled actions. |
Returns
| Type | Description |
|---|---|
| IEnumerable<PublishResult> | The publish results. |
PersistContentSchedule(IContent, ContentScheduleCollection)
Persists publish/unpublish schedule for a content node.
Declaration
void PersistContentSchedule(IContent content, ContentScheduleCollection contentSchedule)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | content | The content to persist the schedule for. |
| ContentScheduleCollection | contentSchedule | The content schedule collection. |
Publish(IContent, string[], int)
Publishes a document.
Declaration
PublishResult Publish(IContent content, string[] cultures, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | content | The document to publish. |
| string[] | cultures | The cultures to publish. |
| int | userId | The identifier of the user performing the action. |
Returns
| Type | Description |
|---|---|
| PublishResult |
Remarks
When a culture is being published, it includes all varying values along with all invariant values.
Wildcards (*) can be used as culture identifier to publish all cultures.
An empty array (or a wildcard) can be passed for culture invariant content.
PublishBranch(IContent, PublishBranchFilter, string[], int)
Publishes a document branch.
Declaration
IEnumerable<PublishResult> PublishBranch(IContent content, PublishBranchFilter publishBranchFilter, string[] cultures, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | content | The root document. |
| PublishBranchFilter | publishBranchFilter | A value indicating options for force publishing unpublished or re-publishing unchanged content. |
| string[] | cultures | The cultures to publish. |
| int | userId | The identifier of the user performing the operation. |
Returns
| Type | Description |
|---|---|
| IEnumerable<PublishResult> |
Remarks
The root of the branch is always published, regardless of publishBranchFilter.
RecycleBinSmells()
Returns true if there is any content in the recycle bin.
Declaration
bool RecycleBinSmells()
Returns
| Type | Description |
|---|---|
| bool |
|
Rollback(int, int, string, int)
Rolls back the content to a specific version.
Declaration
OperationResult Rollback(int id, int versionId, string culture = "*", int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | The id of the content node. |
| int | versionId | The version id to roll back to. |
| string | culture | An optional culture to roll back. |
| int | userId | The identifier of the user who is performing the roll back. |
Returns
| Type | Description |
|---|---|
| OperationResult |
Remarks
When no culture is specified, all cultures are rolled back.
Save(IEnumerable<IContent>, int)
Saves documents.
Declaration
OperationResult Save(IEnumerable<IContent> contents, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<IContent> | contents | The documents to save. |
| int | userId | The identifier of the user performing the action. |
Returns
| Type | Description |
|---|---|
| OperationResult | The operation result. |
Save(IContent, int?, ContentScheduleCollection?)
Saves a document.
Declaration
OperationResult Save(IContent content, int? userId = null, ContentScheduleCollection? contentSchedule = null)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | content | The document to save. |
| int? | userId | The identifier of the user performing the action. |
| ContentScheduleCollection | contentSchedule | The content schedule collection. |
Returns
| Type | Description |
|---|---|
| OperationResult | The operation result. |
SaveAndPublish(IContent, string[], int)
Saves and publishes a document in a single scope.
Declaration
PublishResult SaveAndPublish(IContent content, string[] culturesToPublish, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | content | The document to publish. |
| string[] | culturesToPublish | The cultures to publish, or an empty array for invariant content. |
| int | userId | The identifier of the user performing the action. |
Returns
| Type | Description |
|---|---|
| PublishResult |
Remarks
For invariant content types, culturesToPublish must be empty; the document is
saved and the invariant culture is published.
For variant content types, only the cultures listed in culturesToPublish are
published. Wildcards ("*"), nulls, whitespace and duplicate entries are not accepted. Passing
an empty array saves the document without publishing any culture.
When a culture is being published, it includes all varying values along with all invariant values.
The save and publish run in the same scope. If publishing fails for a business reason (for example, invalid content or an expired schedule) the save still takes effect. Both are skipped when a handler of either the saving or the publishing notification cancels the operation, as the publishing notification is raised before the document is persisted.
The default implementation of this method saves and publishes as two separate operations, so it retains the save when a publishing notification handler cancels. Implementations that combine the two should follow the contract described above.
SaveBlueprint(IContent, int)
Saves a blueprint.
Declaration
[Obsolete("Please use the method taking all parameters. Scheduled for removal in Umbraco 18.")]
void SaveBlueprint(IContent content, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | content | The blueprint to save. |
| int | userId | The identifier of the user performing the action. |
SaveBlueprint(IContent, IContent?, int)
Saves a blueprint.
Declaration
void SaveBlueprint(IContent content, IContent? createdFromContent, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | content | The blueprint to save. |
| IContent | createdFromContent | The content from which the blueprint was created. |
| int | userId | The identifier of the user performing the action. |
SendToPublication(IContent?, int)
Saves a document and raises the "sent to publication" events.
Declaration
bool SendToPublication(IContent? content, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | content | The document to send to publication. |
| int | userId | The identifier of the user performing the action. |
Returns
| Type | Description |
|---|---|
| bool |
|
SetPermission(IContent, string, IEnumerable<int>)
Assigns a permission to a document.
Declaration
void SetPermission(IContent entity, string permission, IEnumerable<int> groupIds)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | entity | The document entity. |
| string | permission | The permission to assign. |
| IEnumerable<int> | groupIds | The group identifiers to assign the permission to. |
Remarks
Adds the permission to existing permissions.
SetPermissions(EntityPermissionSet)
Sets the permission of a document.
Declaration
void SetPermissions(EntityPermissionSet permissionSet)
Parameters
| Type | Name | Description |
|---|---|---|
| EntityPermissionSet | permissionSet | The permission set to apply. |
Remarks
Replaces all permissions with the new set of permissions.
Sort(IEnumerable<int>?, int)
Sorts documents.
Declaration
OperationResult Sort(IEnumerable<int>? ids, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<int> | ids | The document identifiers, in the desired order. |
| int | userId | The identifier of the user performing the action. |
Returns
| Type | Description |
|---|---|
| OperationResult | The operation result. |
Sort(IEnumerable<IContent>, int)
Sorts documents.
Declaration
OperationResult Sort(IEnumerable<IContent> items, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<IContent> | items | The documents to sort, in the desired order. |
| int | userId | The identifier of the user performing the action. |
Returns
| Type | Description |
|---|---|
| OperationResult | The operation result. |
SortChildren(int, IReadOnlyList<int>, int)
Sorts the children of a parent by persisting the supplied (already ordered) child identifiers as the new sort order, in a single set-based update.
Declaration
OperationResult SortChildren(int parentId, IReadOnlyList<int> orderedChildIds, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| int | parentId | The identifier of the parent, or Root for the root. |
| IReadOnlyList<int> | orderedChildIds | The child document identifiers, in the desired order. |
| int | userId | The identifier of the user performing the action. |
Returns
| Type | Description |
|---|---|
| OperationResult | The operation result. |
Remarks
Unlike Sort(IEnumerable<int>?, int), this does not load the children or fire per-item save/sort notifications; it persists the order directly and refreshes the affected cache branch.
Unpublish(IContent, string?, int)
Unpublishes a document.
Declaration
PublishResult Unpublish(IContent content, string? culture = "*", int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | content | |
| string | culture | |
| int | userId |
Returns
| Type | Description |
|---|---|
| PublishResult |
Remarks
By default, unpublishes the document as a whole, but it is possible to specify a culture to be unpublished. Depending on whether that culture is mandatory, and other cultures remain published, the document as a whole may or may not remain published.
If the content type is variant, then culture can be either '*' or an actual culture, but neither null nor empty. If the content type is invariant, then culture can be either '*' or null or empty.