Return to Snippet

Revision: 65859
at January 31, 2014 03:08 by DesignGoggles


Updated Code
<?php

function copyfield_cron() {
	// Get all video nodes
	$type = "video";
	$nodes = node_load_multiple(array(), array('type' => $type));

	foreach($nodes as $node):

		// Extract the video path field.
		$videoPath      =  $node->field_video_path['und']['0']['value'];

		// Save the filed to another field.
		$node->field_video_url['und']['0']['value'] = $videoPath;

		// Save the node
		node_save($node);

	endforeach;

}

Revision: 65858
at January 31, 2014 03:06 by DesignGoggles


Initial Code
<?php

function air_cron() {
	// Get all video nodes
	$type = "video";
	$nodes = node_load_multiple(array(), array('type' => $type));

	foreach($nodes as $node):

		// Extract the video path field.
		$videoPath      =  $node->field_video_path['und']['0']['value'];

		// Save the filed to another field.
		$node->field_video_url['und']['0']['value'] = $videoPath;

		// Save the node
		node_save($node);

	endforeach;

}

Initial URL

                                

Initial Description
This script is a custom module to copy one field to another.

Initial Title
Copy Drupal field to another field

Initial Tags
drupal

Initial Language
PHP