By webchuck on
I am attempting to migrate a group of files into Drupal's flexinode module through a PHP script. I have been searching the forums and API for a simple way to do this, but have found nothing.
So I found a reference to node_save(), which will allow me to add nodes to Drupal outside of the web interface. Great, but...
Issue: Node_save() takes a &$node as its only parameter. So how do I create a node object?
This may be very simple, but I'm new to PHP and Drupal.
I'm sure I'll have other issues after figuring this out, but I'm taking the "baby steps" approach... Can anyone help here?
Comments
Solved by another post...
This forum topic answered my question...
http://drupal.org/node/67887
Next, any APIs for adding flexinodes?
----------------------------------------
Chuck Crandall
WebChuck Web Development
chuck at webchuckweb dot com
----------------------------------------
Same API (node_save)
You would still use node_save(), you just need to know the field names. If you create content based on flexinode and view the source for the form and look at each of the form inputs you will see they are all named something like this
name="edit[some_field_name]". So in the code that builds the node (and before the call to node_save) add lines like$node->some_field_name = 'Some Value';and the flexinode fields will be properly saved.Same API with a tiny bug ?
I've tried to use node_save() with a flexinode, but it seems that $node->type = 'flexinode-1'; is not translate to ctype_id for a good use of flexinode_insert($node).
So, you must add $node->ctype_id = 1; to your code.
Excuse my frenchglish...