When working with the content modules in Sitefinity CMS, you can either directly publish items that you create, or save them as drafts. Those operations create some different versions of the same content behind the scenes, and use a concept that you call content lifecycle. In this article you are going to use the API to perform these operations and compare it with doing the same through the user interface.
Content lifecycle governs whether an item is visible in the frontend, and whether it is being edited. There are four lifecycle states of an item – master, temp, live and deleted. When persisting items in the database, Sitefinity CMS creates one row for each state. You can think of lifecycle states as separate versions of an item. An important characteristic of lifecycle is that an item can be in more than one state at a time (can have several versions). The meaning of each state (item version) is defined in the following table:
The diagram shows how an item moves between the different lifecycle states. The circles represent states, and the arrows represent operations on the item. Each operation triggered by the user interface or API moves an item between states. As already mentioned, those states are actually different versions of an item. To illustrate this, let’s take a look at the state of the database and user interface after each operation. You will use the News module as an example.
In the steps above, you explicitly save the item as draft to illustrate the lifecycle. You can also directly publish the item through the UI, and Sitefinity CMS performs the two operations together in the same order. There will be no difference in the state transitions between those two cases.
Understanding the concept of content lifecycle is important when working with items through the API. Some item operations, however (like scheduling), cannot be performed through the lifecycle alone. They fall into the realm of workflow.
Following is a code sample that demonstrates the above operations:
Sign up for our free beginner training. Boost your credentials through advanced courses and certification. Register for Sitefinity training and certification.
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important