Posted By

DesignGoggles on 01/31/14


Tagged

drupal


Versions (?)

Copy Drupal field to another field


 / Published in: PHP
 

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

  1. <?php
  2.  
  3. function copyfield_cron() {
  4. // Get all video nodes
  5. $type = "video";
  6. $nodes = node_load_multiple(array(), array('type' => $type));
  7.  
  8. foreach($nodes as $node):
  9.  
  10. // Extract the video path field.
  11. $videoPath = $node->field_video_path['und']['0']['value'];
  12.  
  13. // Save the filed to another field.
  14. $node->field_video_url['und']['0']['value'] = $videoPath;
  15.  
  16. // Save the node
  17. node_save($node);
  18.  
  19. endforeach;
  20.  
  21. }

Report this snippet  

You need to login to post a comment.