Tag: add content

  • Adding content programmatically in Drupal 7

    Adding content programmatically in Drupal 7

    Sometimes you really need to add content programmatically and here’s a little sample about the basics. $node = new stdClass(); // Set content type $node->type = ‘article’; // Prepare defaults node_object_prepare($node); // Define language (currently language neutral) $node->language = LANGUAGE_NONE; // Basic content $node->title = ‘Test’; $node->body[$node->language][0][‘value’] = ‘Body text’; // Example if using custom…