On this page
Transport alteration snippets
Last updated on
30 April 2025
This page contains useful snippets for working with Transport data.
Migrate upload module files to filefield
This code is for a Drupal 5 to Drupal 6 migration; it may need altering for D6-D6.
/**
* Implementation of hook_transport_TYPE_prefilter_alter() for node.
*
*/
function MYMODULE_transport_node_prefilter_alter($remote_entity) {
// Get the remote node object.
$remote_node = $remote_entity->entity;
// Migrate upload files to filefield files.
if (isset($remote_node->files) && count($remote_node->files)) {
$remote_node->field_YOUR_FILEFIELD = array();
foreach ($remote_node->files as $fid => $file) {
// Add in missing items that filefield has on a $node.
$file['uid'] = $remote_node->uid;
$file['status'] = 1;
$file['timestamp'] = $remote_node->created;
$file['data'] = NULL;
$remote_node->field_YOUR_FILEFIELD[] = $file;
}
}
Help improve this page
Page status: Not set
You can:
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion