When working with the content modules in Sitefinity CMS, you can either directly publish items that you create, or save them as drafts. These operations create some different versions of the same content behind the scenes. The versions adhere to a strictly defined content lifecycle. This article demonstrates how content lifecycle works, how to use the API to perform these operations, and how to do the same through the user interface.
Content lifecycle governs whether an item is visible on the frontend or whether it is being edited in the backend. There are four lifecycle states of an item:
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 the 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 default state of an item.
Items are always created in Master state first - they always have a master version. Master versions are not visible in the frontend.
An item, which is visible in the frontend.
Once an item is published, Sitefinity CMS creates a live version by copying the item from the master version (the master version continues to exist).
An item that is being edited by a CMS user.
When you open an item for editing, a temp version of the item is created by copying the Master version.
The diagram shows a simplified view of how the information flows between the different lifecycle states of an item. The circles represent the states, and the arrows represent operations on the item. Each operation, triggered by the user interface or the API, moves an item between the states. These states are different versions of an item.
The following process illustrates the state of the database and the user interface after each operation. It uses 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.
RECOMMENDATION: The content lifecycle API is a low level API and does not support all possible scenarios. We recommend using the Web services API instead.
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