Skip to content
Snippets Groups Projects

Issue #3107493: obsolete text in README

2 unresolved threads
+ 107
109
# Default Content
## CONTENTS OF THIS FILE
---------------------
* Introduction
* Requirements
* Installation
* Configuration
* Usage
* Maintainers
## Introduction
_A default content solution for Drupal 8_
[Default Content][1] allows you to export content along with site configuration information. It supports entity-references between content as well as files if you have File entity. Content export works with a set of drush commands (more on those below). Content import happens automatically as part of site installation. The import process scans all modules and imports any content found that is located in the expected file path and using the expected .json file structure. (See detailed information below)
### Features
* Supports entity-references between content
* Supports files if you have File entity
The Default Content module allows you to export content along with
site configuration information. It does so by leveraging core's
serialization and hal modules. It supports entity-references between
content as well as files if you have File entity. Content export works
with a set of drush commands (more on those below). Content import
happens automatically as part of site installation. The import process
scans all modules and imports any content found that is located in the
expected file path and using the expected .yml file structure. (See
detailed information below)
* Easily export your content and its dependencies to yml using drush commands
### Additional Information
* For a full description of the module, visit the project page:
https://www.drupal.org/project/default_content
@@ -33,129 +28,132 @@ _A default content solution for Drupal 8_
## Requirements
* Drupal 8
## Installation
Install as you would normally install a contributed Drupal module. Visit:
https://www.drupal.org/docs/8/extending-drupal-8/installing-drupal-8-modules
for further information.
This module requires no modules outside of Drupal core.
## Configuration
The module has no menu or modifiable settings. There is no configuration. If they are currently disabled, activating default_content will give you the option to enable them.
## Installation
## Usage
Install as you would normally install a contributed Drupal module.
Visit:
https://www.drupal.org/docs/extending-drupal/installing-modules
for further information.
For any module that requires default content, the export process is as follows:
1) Generate a hal+json file for each entity to be exported using the drush commands described below.
2) The entity .json files must be stored in module subdirectories using the following structure: `content/{entity type}/{filename}`, where `{entity type}` will be one of node, taxonomy_term, etc. Filename should be `{entity ID}.json`. For example, a Basic Page with the node ID of 23 would be stored in:
`.../modules/custom/someCustomModule/node/23.json`
Other examples:
## Configuration
- `modules/default_content_test/content`
- `modules/default_content_test/content/node`
- `modules/default_content_test/content/node/imported.json`
- `modules/default_content_test/content/taxonomy_term`
- `modules/default_content_test/content/taxonomy_term/tag.json`
The module has no menu or modifiable settings. There is no configuration.
3) Once your custom module is enabled, the entities you exported will be imported to the new environment during new site installation.
### Note
## Usage
At the moment these files need to be hand-created or exported using the Rest, Hal and Serialization modules.
Note that the default functionality of the Hal module is to make all links point to the origin site's FDQN.
Enable the Default Content module first. Any module that requires
default content can put hal+json versions of the entities (created
with the drush commands) inside content/{entity_type} folders.
The default_content module expects these (at this stage) to be relative to http://drupal.org as there is no point in having default content that can only be re-imported on the originating site.
Once your custom module is enabled, the entities you exported will be
imported to the new environment.
Note that imported.json contains a node with a term reference field that includes a reference to the term in tag.json.
For example, have a look at default_content_test, which has:
The Gliph library (in 8.x core) is used to resolve the dependency graph, so in this case the term is imported first so that the reference to it is created in the node.
- `modules/default_content_test/content`
- `modules/default_content_test/content/node`
- `modules/default_content_test/content/node/imported.yml`
- `modules/default_content_test/content/taxonomy_term`
- `modules/default_content_test/content/taxonomy_term/tag.yml`
### Drush Commands
#### Exports a single entity
Content export works with a set of drush commands.
#### default-content-export
##### default-content-export
Exports a single entity.
Arguments:
- **entity_type:** The entity type to export.
- **entity_id:** The ID of the entity to export.
options:
- **entity_type:** The entity type to export. (required)
- **entity_id:** The ID of the entity to export. (required)
Options:
- **file:** Write out the exported content to a file instead of stdout
aliases: dce
- **required-arguments:** 2
Aliases: dce
**WARNING**
Beware of modules that add extra layers of access control (i.e.
field_permissions and group). By default, drush runs as user anonymous
and may not have access to the fields or nodes.
* Examples:
$ drush dce node 123
Example:
```
$ drush dce node 123 my_default_content_module
```
* Other entity types:
Change the entity type, as we have them in the system.
```
$ drush dce node <node id> my_default_content_module
$ drush dce taxonomy_term <taxonomy term id> my_default_content_module
$ drush dce file <file id> my_default_content_module
$ drush dce media <media id> my_default_content_module
$ drush dce menu_link_content <menu link id> my_default_content_module
$ drush dce block_content <block id> my_default_content_module
```
```
$ drush dce node <node id> (e.g., $ drush dce node 123)
$ drush dce taxonomy_term <taxonomy term id>
$ drush dce file <file id>
$ drush dce media <media id>
$ drush dce menu_link_content <menu link id>
$ drush dce block_content <block id>
```
#### Exports an entity and all its referenced entities
#### default-content-export-references
##### default-content-export-references
Exports an entity and all its referenced entities.
Arguments:
- **entity_type:** The entity type to export.
- **entity_type:** The entity type to export. (required)
- **entity_id:** The ID of the entity to export.
options:
- **folder:** Folder to export to, entities are grouped by entity type into directories.
aliases: dcer
- **required-arguments:** 1
Options:
- **folder:** Folder to export to, entities are grouped by entity type
into directories.
Aliases: dcer
Example:
```
$ drush dcer node 123 my_default_content_module
```
* Examples:
```
$ drush dcer node 123
$ drush dcer node 123 my_default_content_module
```
#### Exports all content defined in a module info file.
#### default-content-export-module
##### default-content-export-module
Exports all content defined in a module info file.
Arguments:
- module: The name of the module.
- aliases: dcem
- required-arguments: 1
Example:
```
$ drush dcem my_default_content_module
```
And add the UUID of entities in my_default_content_module.info.yml file.
```
default_content:
node:
- c9a89616-7057-4971-8337-555e425ed782
- b6d6d9fd-4f28-4918-b100-ffcfb15c9374
file:
- 59674274-f1f5-4d6a-be00-fecedfde6534
- 0fab901d-36ba-4bfd-9b00-d6617ffc2f1f
media:
- ee63912a-6276-4081-93af-63ca66285594
- bcb3c719-e266-45c1-8b90-8f630f86dcc7
menu_link_content:
- 9fbb684c-156d-49d6-b24b-755501b434e6
- 19f38567-4051-4682-bf00-a4f19de48a01
block_content:
- af171e09-fcb2-4d93-a94d-77dc61aab213
- a608987c-1b74-442b-b900-a54f40cda661
```
## To do
UI for easily exporting?
[1]: https://www.drupal.org/project/default_content "Default Content"
[3]: https://www.drupal.org/docs/8/core/modules/serialization "Serialization module"
- **module**: The name of the module. (required)
Aliases: dcem
* Example:
$ drush dcem my_default_content_module
* Relevant contents of my_default_content_module.info.yml:
```
default_content:
node:
- c9a89616-7057-4971-8337-555e425ed782
- b6d6d9fd-4f28-4918-b100-ffcfb15c9374
file:
- 59674274-f1f5-4d6a-be00-fecedfde6534
- 0fab901d-36ba-4bfd-9b00-d6617ffc2f1f
media:
- ee63912a-6276-4081-93af-63ca66285594
- bcb3c719-e266-45c1-8b90-8f630f86dcc7
menu_link_content:
- 9fbb684c-156d-49d6-b24b-755501b434e6
- 19f38567-4051-4682-bf00-a4f19de48a01
block_content:
- af171e09-fcb2-4d93-a94d-77dc61aab213
- a608987c-1b74-442b-b900-a54f40cda661
```
## MAINTAINERS
Current maintainers:
* Sascha Grossenbacher (Berdir) - https://www.drupal.org/u/berdir
* Andrey Postnikov (andypost) - https://www.drupal.org/u/andypost
* Lee Rowlands (larowlan) - https://www.drupal.org/u/larowlan
* Jibran Ijaz (jibran) - https://www.drupal.org/u/jibran
* Sam Becker (Sam152) - https://www.drupal.org/u/sam152
* Ben Dougherty (benjy) - https://www.drupal.org/u/benjy
* Daniel Wehner (dawehner) - https://www.drupal.org/u/dawehner
Loading