The scenario is:

  1. There is a Content Type A node.
  2. I want to create a Content Type B node.
  3. Copy the content of the fields from node type A to the new node type B, including node references.
  4. Delete the original Content Type A node.

Is there a module to achieve at least the step 3? What is the best way to achieve this?

Thanks!!

Comments

fmesco’s picture

The Nodetype module works great for this assuming your Content Type A and Content Type B share the same fields. The module does not allow you to map which fields from Content Type A get mapped to Content Type B however, so any fields from Content Type A that aren't shared in Content Type B will be lost during the switch.

Also, no need to delete the original node from Content Type A since the switch is based on the original node...that node is changed from Content Type A to Content Type B...no "copy" is made. Good luck!

adam_b’s picture

http://drupal.org/project/nodetype is the only alternative I know of - but I don't think it'll do the node references, and it won't delete the original type A node.

taote’s picture

Thanks, but the problem with NodeType is that it doesn´t migrate CCK fields, I guess only title, body and taxonomy.

Does anyone know the best way to do this programatically?

fmesco’s picture

untrue...I use this module to change nodes between 5 different very lengthy cck based content types and it moves the data between the shared cck fields seamlessly.

fmesco’s picture

I should clarify that "move" is actually incorrect. Nodetype doesn't really move anything, it changes the content type in the database. But if you have Content Type A with fields 1, 2 and 3 and Content Type B with fields 1, 2, 3 and 4, the data in fields 1, 2 and 3 will be there in Content Type B after you change the nodetype and you'll have field 4 in the content now too.

taote’s picture

I tried and it didn´t work, and in the specifications it says:

Note: This module is extremely simple and *only* changes the node type in the database column. That is all. It does not convert any CCK fields or change other things about the node.

Are you sure is not Node Convert the module you use?

fmesco’s picture

positive...I've used it this way for over a year on several different installs and it works beautifully. But as you note in your last comment, it won't take two different content types and merge them into a third.

What were the specifics of what you tried that didn't work?

taote’s picture

Thanks to the previous comments, I got to know Node Convert, I think it does what I was looking for.

But know I have a different scenario:

  1. There are Content Type A and Content Type B nodes.
  2. I want to create a Content Type C node with some date from Content Type A node and some from Content Type B node.

Obviously this cannot be achieve with any existing module, so I need to do it programatically. Can anyone some orientation or links for the best practices to achieve that? I mean hooks, best way to create nodes and copy content via PHP in Drupal 6, etc...

Thanks again

mariocantor’s picture

node_convert at https://www.drupal.org/project/node_convert works as you desire, you need to create a new content type with the same fields, be careful because the original node disappear after conversion.
I use this because my content type in openpublish stop working, show me ERROR when i try to edit the node. so I create a new conten type and copy each node.. works node by node....