I have revisions active for a content type, called e.g. "procedures".

When a node of this type is revised, a new vid is assigned, which is a number independent of the number of revisions made on THAT node.

Given the nature of the node, I need to show/store in the node the revision number in a more meaningful way, for example version=1 for the original node, version=2 for the first revision and so on. [edit]: I need to store this information in the database, so that it can be queried whenever it's needed. Also, it needs not to change when a old revision is deleted.

How can obtain such result in a easy, clean way?


1 Answer 1


You can add an integer field to your node, and set the default value to 0.

Then in a small module, use hook_node_presave to increment its value every time the node is saved (or if you detect a field change). Quick, easy and efficient way.

You can do the same with a computed field, by incremeting the value of the field by 1 when you submit the form, but storing code in the database isn't advised.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.