Darren Mothersele

London based Drupal Web Developer
Drupal.org Google+ Facebook Twitter GitHub LinkedIn RSS Feed

Programmatically Creating Drupal Nodes

The Drupal for Developers event was great fun this week. I did a 15 min presentation on Programmatically Creating Drupal Nodes. The slides from this presentation will be going up on the Drupal UK site in the near future, but you can get a preview of the presentation below.

Some of the other developers were able to contribute their own experiences, in particular about how painfully slow drupal_execute() can be.

I presented a case study from a site I have been working on recently where over 5k of content items had to be imported from XML data. I talked about setting up the content types with CCK (and ImageField) as well as creating a compound CCK field in a module, and what hooks to implement in order to create a simple Custom compound CCK field type.

I then went on to explain the import process, converting XML to an array of $field_values for use with drupal_execute().

AttachmentSize
ProgrammaticallyCreatingDrupalNodes.pdf1.88 MB

I was delighted to find your post about creating new nodes pro grammatically via. incoming data through XML since that's EXACTLY what I've been spending the past few weeks struggling with. Unfortunately your file link for the post seems to be down. Your article date indicates it was written pre-Drupal 7; I'd appreciate anything you would have to offer to help in that direction.

Also I have 30 fields for my content type and I'm using the new field API in durpal 7 in place of the deprecated cck. I'm also unsure if that's the best way to go about it considering the number of fields I need.

Thus far I've been able to create my custom content type through my module and I've even figured out that xmlrpc.php is my built-in endpoint which I can hook into with xmlrpc() to map a call back function to a method. I'm still struggling with how to take the xml data and use it to create new content though and would be interested in learning what you might have already discovered. If you have any suggestions/instructions/examples regarding any of the above it would be much appreciated. Thanks in advance.

I came here looking for the same PDF as guest, and the link is still broken.

Note that if you click the link above, you will get "files/" directory twice. Take out one of the "files/" substrings and press enter, OR, use this URL below:

http://www.darrenmothersele.com/files/ProgrammaticallyCreatingDrupalNode...

I've reattached the original file, so both links now work. Thanks!

Post new comment
The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

Recent comments
Latest Posts