Copy Drupal field to another field


/ Published in: PHP
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.