Eventually, markus_petrus did not want to change the current behaviour of the CCK Content Copy module. Therefore, out of box, it won’t allow you to use my way to get CCK content type done programmatically (well, not including the update of them). But let’s forget about this for now. Let’s focus on CCK and the Content Copy module.
From the image above, we can see the standard Content Copy import form. At a first sight, you understand that you can either create a brand new content type out of the code you are going to paste in the textarea or you can import the pasted content type into an existing one.
Or at least, that is what you believe you can do. If you read carefully
This form will import field definitions exported from another content type or another database.
Note that fields cannot be duplicated within the same content type, so imported fields will be added only if they do not already exist in the selected type.
It imports fields. Not content types. What? Why is that? Everything, from the module name, to the menu items, the URL, the breadcrumb, suggests you are about to import a content type.
Unfortunately that is only true if you are about to create a brand new content type out of the code pasted into the form.
We’ve got problems
So we have several problems with the Content Copy import.
First, the interface is not very good, because you can misunderstand what it really does.
Second, if the modules import just fields, than it should also export just fields, and ask the users for the content type details when they require a new content type to be created to import the fields into it. But it does not. It works exporting and importing a full content type definition, which is an inconsistence. So, this module actually exports and imports either just the fields or the whole content type. It depends on your choice. Well, that’s wrong.
Third, we actually have a missing functionality, because we can:
- Create a new content type out of the code;
- Import new fields into an existing content type;
but we can’t
- Update a content type.
But what does “update” really mean? It means you can take an existing content type and import a new definition into it. This implies adding, updating and removing fields, as well as updating the basic informations about the content type, or the fields associations with potential field groups.
This is clearly something that Content Copy does not do. That’s why I created Alternate Content Copy.
Alternate Content Copy
Alternate Content Copy hooks into the Content Copy module, to alter its behaviour. Above you can see the altered interface of the import form. Now it hopefully communicates correctly what it actually does. All the original functionalities are left untouched, I only added a fully functional content type update, i.e. adding, updating and removing fields, as well as updating the basic informations about the content type, or the fields associations with potential field groups.
Even though I am still wondering whether or not I should add a separate entry in the drop-down that says Import the entire content type as update, if you now select the item Import the entire content type, two things can happen:
[...] if this does not exist in the installation, it will be created. On the contrary, if it does exist, it will be replaced with the new version.
And that would be all for now. I will talk about creating CCK content types programmatically again in the next post, in the light of the this new module I wrote.
Download
The module can be downloaded at the following link. It will be soon submitted to the Drupal.org project repository. The version numbering follows the one from the Content Copy module. The beta status is due to the lack of extensive testing. Apart from that, everything looks stable and fine.
Note: There is a file embedded within this post, please visit this post to download the file.
















0 Responses
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.