Versioning

Content items in Orchard are versioned by default: this means that if you edit a content item and publish the modifications you don't overwrite what was previously published but you create a new version - that will be the published version.

Versioning illustrated

Let's take a look at Page content items, because Page is a content type that's included in Orchard by default.

  • Pages are "draftable". This means that you can create draft, i.e. not published (and thus not visible) versions of it. You can also set this option from the admin UI from the content type editor of Page.
  • Pages - among others - include the Title and Body content part. These parts have the capability of being versioned. Not every content part is versionable, it's the developer's decision.

That said let's see what happens:

  1. You create a new Page and save it, i.e. click the Save button. You don't click Publish now. This means the Page is saved, but only as a draft. Nobody can see it on the frontend. The Page only has a single version that is a draft. At the same time this version is the latest version.
  2. You now publish the Page (e.g. click Publish now in the editor). This means the Page is now visible on the frontend. The Page only has a single version that is the published one, which is also the latest.
  3. You now edit the Page and save it. This creates a new version of the Page: one is published (and visible) and one is a draft (not visible). So our Page now has two versions; the draft one is the latest (since it's newer than the published version).
  4. You now edit the Page again and save it. Editing a draft won't create a new version: only editing a published version and saving it will create a new version. So our Page still has two versions, one being the draft with the content you just saved and the other one being the published version.
  5. You now edit the page and instead of clicking Save you click Publish now. This saves the changes to the draft, then publishes it. This means our item still has two versions, both published (the result would be the same if we would just clicked Publish draft from the admin listings: it would made the draft version published).
  6. If you now unpublish the item the latest published item will be pushed back to the draft state. This yields that the first version, the published one will be published and again you'll have the latest version as draft.

Soft deletes

Beware that when you remove content items no record is really deleted as Orchard operates with soft deletes: content items are only marked deleted but remain in the database. Actually what happens is that all version of the content item get unpublished and simultaneously loose their flag of being latest; i.e. in the end no version will be marked as published nor latest, thus the item won't be found when fetching the published version.

However, since the versions are still there, they can be retrieved through the Content Manager.

This page is part of the Orchard Dojo Library!

This page and many others here are part of the open-source, portable package of Orchard 1.x goodies: the Orchard Dojo Library for Orchard 1.x. The Library is freely accessible by anyone; just go to its repository to download its full content (you can even download the textual content of the Library as a big concatenated document in HTML), file issues or fork it! You can even edit it online on Bitbucket, just click on the Edit link in the upper right corner!

Note that the Library also has an Orchard Core version, check it out here!