By vedro-compota on
Hi there!
Guys , writing module I work with $node object in _node_presave($node) hook.
In this hook I successfully get body text by =
$str = $node->body['und']['0']['value'] ;
but I can't access this one =
$node->nid
the error message is =
Notice: Undefined property: stdClass::$nid in
please tell me - how can I get node id from $node object ?
Devel module shows the nid property value in the tab "devel" - but I can't access to it.
As see - there're threads where it's advised to use arg() - but is there other way to do it?
big thanks in advance.
Comments
menu_get_object() also
menu_get_object() also "doesn't help me"
There will not be a nid in
There will not be a nid in hook_presave() when creating new content since the node has not been saved.
_
If creating a new node, there won't be a nid yet. If updating an existing node it should be at $node->nid.
thank you , guys)
thank you , guys)