0

I am importing/updating nodes from a web service using node_save. One feature that I want to achieve is when the imported node is changed locally, it should not receive any further updates from the web service.

So, what I want to achieve is:

  • Detect when a node has been updated
  • If the update was carried out by a user submitting a form (as oppose to programmatically)
  • Then flag that this node should receive no further updates form the web service (I don't need any assistance with this part)

I wanted to use hook_node_update but I'm not sure how to tell whether the update was carried out by a user submitting a form.

Any suggestions?

1

Create an additional field in the content type - for example update_source - and set the value programmatically.

If the user is editing the node on node/[nid]/edit page, set the value to UI and otherwise set it to programmatic.

You can do this with simple hook_form_alter() and URL checks to make sure the user is on node/[nid]/edit page. Something like this would work:

if (arg(0) == 'node' && arg(1) && arg(2) == 'edit') {
  // Your code
}
|improve this answer|||||
  • Thanks for your answer. I'm building a content synchronisation module, so there are many different content types that will be imported. Ideally, I would prefer not to have to add an additional field for each of them. – littledynamo Nov 7 '12 at 10:16
  • Then I suggest custom module which will save the flag value and nid in its own table. – Aram Boyajyan Nov 7 '12 at 12:11

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.