I have a CSV feed running and it currently works perfectly. The client now wants to populate a certain field with a sub-string of another field if the first field is empty, on import. I can't see a way to do that with the normal feeds field mapping or tamper.

How can I achieve this?


Create a custom module, in mymodule.module use hook_node_update

function mymodule_node_update($node) {

  if (!isset($node->field_example[LANGUAGE_NONE][0]['value'])) { 
  // If field example is not set (is empty), then...

     $new_value = // ...do some stuff to compute a new value for the field.
     $node->field_example2[LANGUAGE_NONE][0]['value'] = $new_value;
     field_attach_update('node', $node);



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.