Demo Content

Component ID

2717617

Component name

Demo Content

Component type

module

Maintenance status

Development status

Component security advisory coverage

covered

Downloads

530

Component created

Component changed

Component body

The demo_content module lets you import demo content entities from YAML files. It has support for modules, profiles and themes. It can create and update any content entity types: nodes, blocks, files, images, taxonomy terms, menu links..etc.

See example module and theme: https://github.com/arshad/demo_content_examples

More examples

Usage

To add demo content to your module or theme, add the demo_content info to your .info.yaml file. Example:

example.info.yml

name: 'Example Theme'
type: theme
description: 'Description for theme'
core: 8.x
version: 8.x-1.0-dev
demo_content:
  - content/file.file.yml
  - content/node.article.yml

Then create your demo content as follows:

file.file.yml

entity_type: file
bundle: file
content:
  file_1:
    uuid: 61bdc2a3-d56d-443f-8488-10ca4ab7b42a
    path: $PATH$/images/wild.jpg
  file_2:
    uuid: 691b01e8-2af4-4b53-916d-f38033af5cb6
    path: $PATH$/images/cacheme.jpg

node.article.yml

entity_type: node
bundle: article
content:
  article_1:
    uuid: 0f22e197-ada3-4833-911b-fb75dcbb0ff8
    title: 'Lipsum dolor sit amet'
    path_alias: '/lipsum-dolor'
    body:
      value: '<p>Lipsum dolor sit amet from dsadsa Demo Content.</p>'
      format: full_html
    field_image:
        entity_type: file
        uuid: 61bdc2a3-d56d-443f-8488-10ca4ab7b42a

You can also use the UI to import entities:

Roadmap

  • Batch for importing entities.
  • Add support for dependencies.
  • Export entities feature.
  • Add tests

Similar modules

https://www.drupal.org/project/default_content