1

I'm using the entity_translation_insert() hook to set the value of a field when a node is translated. I can successfully edit the $entity from within the implementation, but how should I save the resulting node?

I can't call node_save because it would start an endless loop. I tried field_attach_update but the result is the same (i.e. loop).

I've tried following this article, with no luck: http://anthonypower.com/notebook/assigning-node-field-values-hook-insert-and-update-right-way

0

A trick to bypass this could be to use a static variable to process nodes only once per request, e.g.

/**
 * Implements hook_entity_translation_insert().
 */
function yourmodule_entity_translation_insert($entity_type, $entity, $translation, $values = array()) {
  static $processed = array();
  if ($entity_type == 'node' && !isset($processed[$entity->nid])) {
    // Do something
    $processed[$entity->nid] = TRUE;
  }
}

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.