I'm trying to get the content of the Node title (node.title
) of one content type into a CCK field (content_field_title.field_title_value
, I guess) in the same content type (and then strip a pattern from the title, but that's a different issue).
After looking into the CCK database tables I don't think that I can manage to do this with a simple INSERT/UPDATE SQL statement. So I was hoping that something like this might be into the scope of the VBO module.
In #852020: How to copy contents of Body field to CCK field? a similar issue was discussed; to get the node's body into a field, this statement was suggested:
return array(
0 => array('value' => $node->body, 'format' => $node->format),
);
As a non coder I'd guess that the I'd need $node->title
, but neither node titles nor my target CCK field accepts a format. So maybe I would end with something like this?
return array(
0 => array('value' => $node->title),
);
Where would I enter this in VBO (probably action "Execute arbitrary PHP script")?
After reading #729962: Copy data in CCK field to Body field I tried this PHP snippet which didn't work for me:
$object->title = $object->field_title[0]['value'];
node_save($object);
So I'm pretty stuck with this. A generic action to copy and/or move content between fields for non coders would be a really great addition to VBO! Something like Field Copy, but with support for Drupal core "fields" like title and body...
Thanks & greetings, -asb
Comments
Comment #1
infojunkieTry "Execute arbitrary PHP script" with the following script:
Comment #2
asb CreditAttribution: asb commentedThe snippet you provided works perfectly, thank you very much!
However, I'd still love to see a generic solution to move/copy/merge field data which can be used by non coders (after browsing through my database table I've seen so much stuff I'd like to move around, e.g. old coordinates from the 'location' module, duplicate fields from 'amazon' field etc.).
What do you think about changing this (back) into a feature request for a future VBO version, maybe a capable coder will give it a shot?
Thanks again & greetings, -asb
PS: I started a handbook page for this: Copying data between fields with VBO
Comment #3
infojunkieReverted to a feature request. Thanks for the handbook page!
Comment #4
bojanz CreditAttribution: bojanz commentedClosing old issue.
VBO at this point supports tokens in the "modify field values" / "modify entity values" actions, which should be enough to start swapping values.
If not, perhaps a contrib module can provide a more complex approach.