[development] what's the best way to create nodes from code?
Emma Irwin
emma.irwin at gmail.com
Fri Oct 30 18:34:14 UTC 2009
Isn't there a need for node_submit() as well before node_save(); ?
On Fri, Oct 30, 2009 at 9:52 AM, Alex Barth <alex at developmentseed.org>wrote:
>
> If speed is not an issue, use drupal_execute(). You're on the safe side
> with it, you don't need to worry about hook_nodeapi() / hook_form_alter()
> implementations of the moduls in use.
>
> Otherwise, I settled for:
>
> $node = new stdClass();
> node_object_prepare($node);
> // Add stuff.
> $node->title = 'my title';
> node_save($node);
>
> On that note, I urge all module developers to not rely on form submission
> in their hook_nodeapi() implementations. Your module's node api
> implementation shouldn't break when a node is being created without using
> the way through the form api.
>
>
> On Oct 30, 2009, at 11:53 AM, Zhang Xiao wrote:
>
> Hi,
>>
>> I have a batch of nodes need to be created from code, which function
>> should i use as an entry?
>>
>> thanks!
>>
>
> Alex Barth
> http://www.developmentseed.org/blog
> tel (202) 250-3633
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20091030/02ba16fe/attachment.html
More information about the development
mailing list