Learn about the revision system in Drupal.
We’ll cover the following:
- How to access the revision page
- Creating a revision
- Viewing old revisions
- Reverting revisions
In Drupal, when you update content, the changes can be tracked using revisions. To demonstrate this, let’s create another product page. Click on add content, then product. And in the title field, I’ll enter in “How to install Drupal” as the title. Let’s price this product at $20. And let’s also add in some product summary text. Then if we scroll down, let’s make sure that the product type is set to course. And then scroll all the way down and click on save. Here you can see the product that we just created. We have the product summary, price, and also the product type. You should also see this revisions tab. If you can’t see it, it could be that your user account doesn’t have access to view revisions or revisions haven’t been configured on the content type. But if you have administrator access to your Drupal site, you should see it.
If we go into the revisions page, we should see a single revision because we have just created this product page. And under the operations column, you can see that it’s set as the current revision. Let’s now create a new revision by clicking on edit. And let’s scroll down to the body field and I’ll paste in some random text. From the column on the right, we can control if a revision will be created by checking the create new revision checkbox. We can also add a revision log message, which will be shown on the revision page. The create new revision checkbox on the right is automatically checked because we have configured the product content type to create revisions.
If we go to structure, and I’ll open that up in a new tab, then content types, and let’s edit the product content type. And then if we go to the publishing options section, you can see that the create new revision under default options has been checked. This means that the create new revisions on the product edit form will automatically be checked. If you prefer revisions not to be created by default, then just uncheck this checkbox. Let’s jump back to the product edit form. And let’s add in a revision log message, then scroll down and click on save. Then if we go into revisions, we should see the two revisions in the table. We have the current one, which is up the top. And on the left, we have the revision log message, which is added body text. And then below that revision, we have the previous revision.
If you want to see what a previous revision looks like, just click on the date and time on that revision. So if we click on this link, we can see what this product looked like at this revision. From the operations column, you can revert a revision or you can even delete a revision. Let’s revert to this first revision. So to do that, just click on revert, and then click on the revert button. And now we can see a brand new revision, which is a copy of the first revision. And in the revision log message, it tells you exactly which revision you reverted to. And then if we click on view, we can see that the body field is no longer there because we reverted to the first revision, which just had a product summary, price, and product type.