Node Type Revisions adds a node_type.type field to the node_revisions table schema. This allows the content type to be tracked within node revisions. This module also adds a local task to modify a node's content type.
Requirements
Warnings & Caveats
I'm not going to lie here: this is definitely a hack, and not endorsed for production websites. There are a lot of factors to take into consideration. Most importantly, although Drupal core and CCK handle this quite well without any additional code in the module (perhaps entirely by accident), this might be changed in future APIs (e.g., Drupal 7). Second, I wrote this module for a very specific purpose in a locked down intranet application, and while it works fine in that setting, caveat emptor.
Here are a few CCK-specific issues:
- Any CCK fields must be the same field declaration if you want to carry the data from one type to another. Fields not found in the new type will be completely ignored.
- Special attention should be paid to field types that have separate settings for each instance. In certain cases, there may be some data loss, or at least some confusion.
- Switching from one node type to another, and then back again, does NOT restore or preserve data that was lost from fields found in one type but not the other. For example, if you switch from Event (which would have CCK date fields specific to the Event type) to Page (which is just title and body), the event's date is lost. Switching back to Event from Page does not restore this data, even though the field structure is restored.
- If you're feeling hacky, you could rewrite this module to
node_load the most recent Event type revision, and merge the data together. Of course, this might require a heuristic for handling field conflicts.
- If you restore from a old revision, the data is preserved. This is because the content type is stored with the node revision, and field instances & field content are loaded by
node_load.
Installation & Use
- Copy the Node Type Revisions module files to your site's modules directory, or "/sites/all/modules." Enable the module in your site administration.
- Once the module has been installed, navigate to any node and click Edit Type in the tabs (local tasks).
- Change the type in the drop-down select field, and click Submit. The module will now save a new revision to the database with the new content type. This change is noted in the log for the revision.
- Viewing the Revisions table will allow you to restore to the older version at any point.