CCK – Alternate Content Copy

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.

Content Copy import form

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 import form

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 from its project page on drupal.org. 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.

Tags: , ,

11 Responses to “CCK – Alternate Content Copy”

  1. James
    6 July 2010 at 11:35 pm #

    excellent module. why have you not put this valuable code into the drupal contrib repository?

  2. Vincenzo
    7 July 2010 at 10:16 am #

    @James: it’s there actually, I’ve just not updated my blog to say so :)

    http://drupal.org/project/acc

    Still in dev.

  3. James
    7 July 2010 at 3:21 pm #

    awesome! thanks for the update.

  4. Vincenzo
    8 July 2010 at 2:34 pm #

    You’re welcome. Cheers

Trackbacks/Pingbacks

  1. Domus Neminis » Programmatic CCK Content Types – The Patch - 3 December 2009

    [...] // Drupal // 2 comments UPDATE 02/12/10: this patch is out of the date, please refer to the Alternate Content Copy module [...]

  2. Domus Neminis » Programmatic CCK Content Types – Updated - 4 December 2009

    [...] CCK Content Types programmatically, including the ability of updating them via code. After some events, the HowTo needed an update, as it now (necessarily) depends on the Alternate Content Copy [...]

  3. Domus Neminis » Programmatic CCK Content Types: why my way? - 7 December 2009

    [...] A few days ago, I have announced the Alternate Content Copy module, which hopefully is going to be accepted on the Drupal.org project repository (as soon as I submit it). [...]

  4. [Vincenzo Russo] Programmatic CCK Content Types: why my way? – techPortal - 7 December 2009

    [...] A few days ago, I have announced the Alternate Content Copy module, which hopefully is going to be accepted on the Drupal.org project repository (as soon as I submit it). [...]

  5. [Vincenzo Russo] Drupal and its community issues – techPortal - 20 February 2010

    [...] trying to contribute a patch to the Content Copy module. You can read the whole thread as well as some of my recent posts to know about all the technical [...]

  6. Domus Neminis » Drupal and its community issues - 10 March 2010

    [...] trying to contribute a patch to the Content Copy module. You can read the whole thread as well as some of my recent posts to know about all the technical [...]

  7. [Vincenzo Russo– The Patch]Programmatic CCK Content Types – The Patch – techPortal - 26 August 2010

    [...] 10, 2010 UPDATE 02/12/2009: this patch is out of the date, please refer to the Alternate Content Copy module [...]

Leave a Reply