function devel_generate_content_add_node

cis7 devel_generate.inc devel_generate_content_add_node(&$results)
cle7 devel_generate.inc devel_generate_content_add_node(&$results)
elmsmedia7 devel_generate.inc devel_generate_content_add_node(&$results)
icor7 devel_generate.inc devel_generate_content_add_node(&$results)
meedjum_blog7 devel_generate.inc devel_generate_content_add_node(&$results)
mooc7 devel_generate.inc devel_generate_content_add_node(&$results)

Create one node. Used by both batch and non-batch code branches.

Parameters

$num: array of options obtained from devel_generate_content_form.

2 calls to devel_generate_content_add_node()
devel_generate_batch_content_add_node in sites/all/modules/ulmus/devel/devel_generate/devel_generate_batch.inc
devel_generate_content in sites/all/modules/ulmus/devel/devel_generate/devel_generate.inc
The main API function for creating content.

File

sites/all/modules/ulmus/devel/devel_generate/devel_generate.inc, line 667

Code

function devel_generate_content_add_node(&$results) {
  $node = new stdClass();
  $node->nid = NULL;

  // Insert new data:
  $node->type = array_rand($results['node_types']);
  node_object_prepare($node);
  $users = $results['users'];
  $node->uid = $users[array_rand($users)];
  $type = node_type_get_type($node);
  $node->title = $type->has_title ? devel_create_greeking(mt_rand(2, $results['title_length']), TRUE) : '';
  $node->revision = mt_rand(0, 1);
  $node->promote = mt_rand(0, 1);
  // Avoid NOTICE.
  if (!isset($results['time_range'])) {
    $results['time_range'] = 0;
  }

  devel_generate_set_language($results, $node);

  $node->created = REQUEST_TIME - mt_rand(0, $results['time_range']);

  // A flag to let hook_nodeapi() implementations know that this is a generated node.
  $node->devel_generate = $results;

  // Populate all core fields on behalf of field.module
  module_load_include('inc', 'devel_generate', 'devel_generate.fields');
  devel_generate_fields($node, 'node', $node->type);

  // See devel_generate_nodeapi() for actions that happen before and after this save.
  node_save($node);
}
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.