Skip to content

Tiny improvement on 'creating_nodes'

Hi David,

https://gitlab.com/davidjguru/drupal-custom-modules-examples/-/blob/master/creating_nodes/creating_nodes.install#L110 should get the nid from the article you just saved.

$nid = $node_article->id();

Thanks for sharing the code and the elaborate blog post at https://davidjguru.github.io/blog/drupal-snippets-creating-nodes-by-code