Modify news items

When editing a news item, you must work with its master version. To modify an item, you must perform the following:

  1. Get the master version.

    Get the master version of the news item. When you modify an item, you must not work on its live version.

  2. Get a temp version.

    Check out the master version to get a temp version of the item.

  3. Modify the temp version.

    Set the properties of the temp version to the new values.

  4. Update the master version.

    Check in the temp version to transfer the changes to the master version.

  5. Update the live version.

    Publish the master version to transfer the changes to the live version.

The example below shows you how to modify a news item by the ID of its master version. For more information about working with the ID of the live version, see For developers: Edit content in For developers: Content lifecycle.

Modifying news items by the ID of its master version

The following code modifies a news item by the ID of its master version.

Native API

First, you get an instance of the NewsManager class. Then, you get the master version corresponding to the ID. To get a temp version of the item, you call Lifecycle.CheckOut with the master version as an argument. You make all the modifications to the temp version. In this example you update the title of the news item and its URL. To transfer the changes to the master version, you call Lifecycle.CheckIn with the temp version as argument. By default, when calling the CheckIn method, the temp version gets deleted. Then, you call SaveChanges to persist the changes. Finally, to publish the news item, you call the MessageWorkflow method of the WorkflowManager class and pass the required parameters.

Fluent API

First, you check whether an item with the specified ID exists. Then, you get the singular news item facade of the master version with the specified ID. To get the facade of the temp version, you call the CheckOut method. You make all the modifications in the Do method of the temp facade. In this example you update the title of the news item and its URL. To transfer the changes to the master version of the item, you call CheckIn. To you save the changes, you call SaveChanges. Finally, to publish the news item, you call the MessageWorkflow method of the WorkflowManager class and pass the required parameters.

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Get started with Integration Hub | Sitefinity Cloud | Sitefinity SaaS

This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.

Web Security for Sitefinity Administrators

This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?

Next article

Delete news items