[development] programmatic creation of node

Victor Kane victorkane at gmail.com
Mon Mar 10 12:42:25 UTC 2008


On Mon, Mar 10, 2008 at 10:16 AM, Earnie Boyd <earnie at users.sourceforge.net>
wrote:

> Quoting Victor Kane <victorkane at gmail.com>:
>
> > I do this a lot, so I will ad my two cents.
> >
> > The following line is absolutely essential for "good housekeeping",
> > especially if you are using cck fields:
> >
> > $node = node_submit($node);
> >
> > However, it will NOT work if ... it shouldn't; for example if you omit
> (as
> > does the above code) initializing the uid attribute.
> >
>
> Which is what http://api.drupal.org/api/function/node_object_prepare
> does when nid is not set in the node object.


OK, great. But I thought I read KarenS stating somewhere that the
node_submit($node) was good when we are dealing with CCK fields... would be
good to know

Victor


>
>
> > So, use this function, and include all the necessary fields to make it
> work,
> > it is a good test.
> >
> > Larry is right, what is needed is a better solution...
> >
>
> mymodule_nodeapi?  Filter on ``presave'' value for $op?  Then the main
> code just does the node_save.
>
>
> Earnie -- http://for-my-kids.com/
> -- http://give-me-an-offer.com/
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20080310/b8440702/attachment.htm 


More information about the development mailing list