Posted by 4lvin on October 8, 2012 at 4:36am
Can i pass the Node Object $node to another Drupal Instance (another Drupal Site) ?
- Lets just forget about Node Conflictions .. and problems etc..
- And lets assume i have a $node in a Script
- Then....
- Is it POSSIBLE to pass a Drupal Node Object $node to another Drupal Instance? (to continue working on that $node at the destination Instance end)
- How can i pass a $node to another Drupal Site?
Comments
You probally need to use the
You probally need to use the services module or something similair.
XML-RPC or JSON-RPC are the easiest ways to connect 2 drupal sites together and send a node from one to another.
the original form of a $node Object?
Ok. The major question here is:
Is it safe to keep the original form of a $node Object?
I mean, can i simply re-use that, passed, $node Object as exactly as it was a Drupal Node, at the destination site (script)?
To be more clear, can it still be a valid/pure Drupal $node Object at the destination end?
Well JSON can only handle
Well JSON can only handle objects or arrays, not both at the same time, so in that case you need to transform the data you get so it can be saved on the recieving website.
if the 2 website have the same fields then you only need to remove the $node->nid and $node->vid, before saving the node on the recieving website.
If you are using JSON to send node data, make sure to read the data as an array:
json_decode($json, true)A node is on the first layer always an object, but afterwards it's almost always an array.
So you can can transform the first layer back to an object if needed.
HOWEVER I think the services module probally allready got something that handles sending nodes to a different drupal install.