Create a content node from another content I'm wondering how to create a content from another content. I'll give an example, it will be easier to understand :

We have a content-type "Planning" which has three fields : 2 user references and one date, which can be multiple filled (let's say the dates are appointments). So in result, a planning will link 2 users and this node will display all the dates these 2 are supposed to meet.

Also, we have another content-type "Appointment".

I'd like that after the creation of the Planning, the appointments get automatically created, always linking the 2users.

First, I've looked into the module Flexi-Field but it doesn't create the node. Then I thought about Rules but I don't know how to create the multiple nodes Appointments due to the multiple date fields.

I know I could do it with Rules through a PHP custom code, but if there's any easier solution, I'd like to hear about them :-)

Thanks for any suggestion !

Cheers all !
If both your content types are defined for Plannning and Appointment already, you can easily create appoint nodes on-the-fly when a Planning node is saved.

You want to look at the following 2 references:


hook_node_insert()
Programmatically create nodes


It would look something like this (NOT TESTED):

function mymodule_node_insert($node) {
  if ($node-&gt;type == 'planning') {
    foreach (element_children($node-&gt;field_appointment_dates) as $a_single_appointment_date) {
      $appt_node = new stdClass();
      $appt_node-&gt;type = 'appointment';
      node_object_prepare($appt_node);
      $appt_node-&gt;language = LANGUAGE_NONE; // Or your language type ...
      $appt_node-&gt;title = 'Some new appointment';
      $appt_node-&gt;field_appointment_date = $a_single_appointment_date[0]['value'];
      node_save($appt_node);
    }
  }
}