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  

Comments

RSS Icon Subscribe to comments
Posted By: frankie1435 on October 12, 2018

Hi,

I'm a newbie in Drupal and was wondering if you could help me out; I am using Drupal 7 and have a content type named "publications" and in that content type I have a node reference called "authors", a text field called "authorstext" and a text and node reference field called "authors2" what I want to do is copy everything from the node reference field "authors" and the text field "authorstext" to the text and node reference field called "authors2". I'm trying to use VBO with an arbitrary PHP code but nothing seems to be working; any help would be super helpful; thanks so much!

You need to login to post a comment.