📜  dotcms contentidentifier - C# (1)

📅  最后修改于: 2023-12-03 14:40:51.891000             🧑  作者: Mango

dotCMS Content Identifier

The dotCMS Content Identifier refers to a unique identifier assigned to every piece of content within the dotCMS content management system. This identifier is used to retrieve and manipulate content through the dotCMS API.

Retrieving Content by Content Identifier

To retrieve content by its identifier, you can use the ContentletAPI class in dotCMS. Here's a sample C# code snippet showing how to retrieve a contentlet by its identifier:

using DotNetCMS.API;
using DotNetCMS.API.Models;

// assume we have a contentlet identifier stored in a variable named contentIdentifier

// create a new instance of the ContentletAPI class
var contentletApi = new ContentletAPI();

// retrieve the contentlet by its identifier
ContentletModel contentlet = contentletApi.GetContentletByContentIdentifier(contentIdentifier);

Updating Content by Content Identifier

To update content by its identifier, you can also use the ContentletAPI class in dotCMS. Here's a sample C# code snippet showing how to update a contentlet by its identifier:

using DotNetCMS.API;
using DotNetCMS.API.Models;

// assume we have a contentlet identifier stored in a variable named contentIdentifier

// create a new instance of the ContentletAPI class
var contentletApi = new ContentletAPI();

// retrieve the contentlet by its identifier
ContentletModel contentlet = contentletApi.GetContentletByContentIdentifier(contentIdentifier);

// update the contentlet fields
contentlet.Title = "New Title";
contentlet.Body = "New Body";

// save the changes
contentletApi.UpdateContentlet(contentlet);
Conclusion

The dotCMS Content Identifier is a crucial element in manipulating content in dotCMS. With this unique identifier, developers can easily retrieve and update content through the dotCMS API.