converting from video project to emfield

Last updated on
30 April 2025

This may not be elegant, but it worked.
Here is what I used to migrate from the video module.
This was my first php script so be sure you are backed up.

<?php
// Bootstrap Drupal
require 'includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
require 'modules/node/node.pages.inc';
 
  // Construct the new node object once for all
  $node = new stdClass();
  $node->type = 'video_url';
$node->language = 'en';

// Query all the nodes.
$result = db_query("SELECT nid FROM {node} WHERE type = 'video'");
 
// Loop through all the nodes.
while ($nid = db_fetch_object($result)) {
  // Load the node.
  $old_node = node_load($nid->nid);
node_object_prepare($node); // just filled in default values for uid, status, promote, status, date, created, and revision properties 

  // Migrate the video-url-field to emfield
$node->title = $old_node->title;
$node->body = $old_node->body;
$node->field_video_url[0]['embed'] = $old_node->vidfile;
$node->taxonomy = $old_node->taxonomy;

// creates a new node
 $node->nid=''; 

  // Save the changes
  node_save($node);
}
?>

This created the new emfield nodes. Then I went to /admin/content/node to select and delete the old video nodes. I also ran the update "reload embedded media data" which I ran on my new nodes (just in case).
Note that this only does external video URLs, someone else will have to write the part for local video files. Refer to http://geeksandgod.com/tutorials/computers/cms/drupal/drupal-converting-...

Help improve this page

Page status: Not set

You can: