Closed (fixed)
Project:
Node factory
Version:
5.x-1.x-dev
Component:
Miscellaneous
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
25 Jan 2008 at 20:04 UTC
Updated:
29 Jan 2008 at 14:51 UTC
when working with multiple content types that are related to each other, i've needed to obtain the new node id. i had to do this with a separate call to the database, so, to improve the node_factory_save_node function, i've made a slight modification to return the new node value, or false if it wasn't created.
i've also patched the < at the start of the file :)
| Comment | File | Size | Author |
|---|---|---|---|
| node_factory.module.patch | 1.1 KB | George2 |
Comments
Comment #1
clemens.tolboomGreat suggestion.
I applied part of the patch.
- returning nid when saved.
- returning nothing when not saved. Hope this makes more robust code.
Regards,
Clemens
Comment #2
clemens.tolboomComment #3
George2 commentedto be anal, i think the save_node should return false if it wasn't successful ;)
to assign the output of a function to a variable, then test if that variable was really set, just, doesn't feel right!
if (($nid = node_factory_save_node($edit)) != false){
// ... good stuff
}
else{
// ... not successful
}
to be really anal, it should return true if the node save was successful imo, but that would prove a problem with retrieving the id, so this is a good middle ground?
of course, if this was oop, it'd be a lot easier - $edit->getNodeId() ;)
Comment #4
clemens.tolboomreturn value is now FALSE