Hi,
i use node_convert to convert node from content type to another

How i can convert node type with "media_youtube" field to anothe type node with "youtube" field.

"youtube" and "media_youtube" is two drupal module using youube link to creat image ad video insid node.

Thanks.

Log in or registe

Comments

guschilds’s picture

Status: Active » Closed (won't fix)

Hey rachidik,

I've never used the Node Convert module before, but I went ahead and gave this a shot.

I installed Drupal with Node Convert, YouTube Field, and Media: Youtube. I created a content type with a YouTube Field field and another content type with a Media field. I went to the Node Convert screen to create a template to convert the Media field to the YouTube Field field. I ended up at a form that read:

field_media_video should be inserted into:

My options were:

  • discard
  • Append to body
  • Replace body

I looked into how that form was built to determine how it was creating those options. I ended up on this code within node_convert.forms.inc:

        $options = array();
        $options['discard'] = 'discard';
        $options[APPEND_TO_BODY] = t('Append to body');
        $options[REPLACE_BODY] = t('Replace body');

        // Insert destination type fields into $options that are of the same type as the source.
        foreach ($dest_fields as $dest_field_name => $dest_value) {
          if ($fields_info[$source_field_name]['type'] == $fields_info[$dest_field_name]['type']) {
            $options[$dest_value['field_name']] = $dest_value['field_name'];
          }
        }

Notice the comment, Insert destination type fields into $options that are of the same type as the source., and code underneath it. Apparently this module will only convert fields that are the same type. YouTube Field fields and Media fields are not the same type so I don't think this module could be used to do this.

These modules also appear to store data in very different ways. If you were to write custom code to accomplish this, you'd probably have to reach for the file entities stored by the Media module, extract the YouTube ID from their uri, and save that ID in the YouTube Field's row. Yikes!

Sorry this wasn't easier, but I hope the answer helps!