[development] programmatic creation of node
Novák Áron
aron at novaak.net
Sat Mar 8 15:53:50 UTC 2008
Hi!
While the development of FeedAPI, i faced with a problem. FeedAPI has to
create nodes programmatically, i believed that this is a really easy thing to
do, feedapi now works like this:
$node->data1 = "foo";
$node->data2 = "bar";
node_object_prepare($node); // this is about the default values
node_save($node);
But I got a report that this is not a good way to do:
http://drupal.org/node/196273
Summary:
"node_object_prepare() and node_prepare() functions are meant to simulate the
demonstration of a node"
And some users, who use FeedAPI + 3rd party modules together, really
experience bugs around node creation / handling:
http://drupal.org/node/195105 (summary: the core forum module uses form_alter
to pass taxonomy-like data. And this data is lost now.)
Can you suggest me a perfect way to handle this problem?
mustafau (http://drupal.org/user/207559) suggested to use
drupal_execute($form_id, $form_values), but in this case, i had another
problem: drupal_execute has no useful return value and $node structure
remains unaltered, so i had to do a node_load after this, which is quite
expensive.
Thanks,
Aron Novak
More information about the development
mailing list