0

I created a content type "cities", with Fields: Title, body, location(text field)

I would like to create about 200 pages for this content type.

I can create manually one by one. It will take a lot of time to do that. Is there faster way I can add the pages by using some bulk load methods?

2
  • You can look into the Feeds (Drupal 7 only) or Migrate (Drupal 7 & 8) modules to import data from a csv. Commented Jan 13, 2018 at 19:58
  • any feedback about my answer? Commented Feb 5, 2018 at 21:39

2 Answers 2

1

Use the Devel module, and its devel_generate submodule.

Using this submodule, you can perfectly create 200 nodes (with randomly generated content) of any content type.

1

You can create the nodes from a php array:

use Drupal\node\Entity\Node;
use Drupal\node\NodeInterface;


    $values = [
      'type' => 'my_content_type',
      'title' => 'test title',
      'body' => [
        [
          'value' => 'test body',
          'summary' => '',
          'format' => 'filtered_html',
        ],
      ],
      'field_location' => 'test locatation',
      'status' => NodeInterface::PUBLISHED,
    ];

    $node = Node::create($values);
    $node->save();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.