[development] programmatic creation of node

Clemens Tolboom clemens at build2be.nl
Sun Mar 9 11:54:13 UTC 2008


I created http://drupal.org/project/node_factory for programmatic  
creating nodes. It is not complete let alone flawless :-/

This thread is now documented in http://drupal.org/node/231922 ...

Is it wise to consolidate these findings into this module? We can  
collect best practive into this module as a documented example and a  
useful module for the less fortunate programmers.

I started this module as a php 'integration' with workflow_ng where  
simple cck fields are usable. But I got stuck with ie imagefield.

Regards,
Clemens

Op 8 mrt 2008, om 16:53 heeft Novák Áron het volgende geschreven:

> 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