Skip to content
Snippets Groups Projects
Commit 710e149a authored by Manoj Raj's avatar Manoj Raj Committed by Damien McKenna
Browse files

Issue #3320034 by Manoj Raj.R, nitapawar, DamienMcKenna: Replace README.txt with README.md format.

parent b4b41d5d
No related branches found
No related tags found
No related merge requests found
-- Summary --
# YAML Content
The YAML Content module provides a framework for defining content in a
human-readable and writable YAML structure allowing for the flexible
and straight-forward creation of demo content within a site.
-- REQUIREMENTS --
No additional modules are explicitly required for yaml_content to function.
## Requirements
-- INSTALLATION --
No additional modules are required for YAML Content to function.
* Install as usual, see https://www.drupal.org/documentation/install/modules-themes/modules-8
for further information.
-- SETUP --
## Installation
Install as you would normally install a contributed Drupal module. For further
information, see [Installing Drupal Modules](https://www.drupal.org/docs/extending-drupal/installing-drupal-modules).
## Configuration
No configuration is provided in the UI.
Recommended setup for the module is to determine a target location for import
content to be found. Most accessibly, this could be within either an enabled
......@@ -24,7 +29,8 @@ subdirectory and follow the naming convention `*.content.yml`. Referenced images
or data files may also be added in parallel directories named `images/` and
`data_files` respectively.
-- USAGE --
## Usage
To assist determining YAML structure for entities and fields, looking at the
structure within the corresponding entity_view_display configuration file is a
......@@ -33,11 +39,12 @@ good place to start.
Once content is created for import, it may be imported through the one of the
custom Drush commands:
- `drush yaml-content-import <directory>`
- `drush yaml-content-import-module <module_name>`
- `drush yaml-content-import-profile <profile_name>`
drush yaml-content-import <directory>
drush yaml-content-import-module <module_name>
drush yaml-content-import-profile <profile_name>
-- EXAMPLES --
## Examples
For some brief content examples, have a look in the `content` folder of this
module. In that folder there are example import files with inline commentary
......@@ -51,39 +58,47 @@ following command through Drush:
drush yaml-content-import-module yaml_content
-- INSTALLATION PROFILE USAGE --
## Installation profile usage
To trigger loading content during an installation profile just add an install
task.
/**
* Implements hook_install_tasks().
*/
function MYPROFILE_install_tasks(&$install_state) {
$tasks = [
// Install the demo content using YAML Content.
'MYPROFILE_install_content' => [
'display_name' => t('Install demo content'),
'type' => 'normal',
],
];
return $tasks;
}
/**
* Callback function to install demo content.
*
* @see MYPROFILE_install_tasks()
*/
function MYPROFILE_install_content() {
// Create default content.
$loader = \Drupal::service('yaml_content.load_helper');
$loader->importProfile('MYPROFILE');
// Set front page to the page loaded above.
\Drupal::configFactory()
->getEditable('system.site')
->set('page.front', '/home')
->save(TRUE);
}
/**
* Implements hook_install_tasks().
*/
function MYPROFILE_install_tasks(&$install_state) {
$tasks = [
// Install the demo content using YAML Content.
'MYPROFILE_install_content' => [
'display_name' => t('Install demo content'),
'type' => 'normal',
],
];
return $tasks;
}
/**
* Callback function to install demo content.
*
* @see MYPROFILE_install_tasks()
*/
function MYPROFILE_install_content() {
// Create default content.
$loader = \Drupal::service('yaml_content.load_helper');
$loader->importProfile('MYPROFILE');
// Set front page to the page loaded above.
\Drupal::configFactory()
->getEditable('system.site')
->set('page.front', '/home')
->save(TRUE);
}
## Maintainers
- [Damien McKenna](https://www.drupal.org/u/damienmckenna)
- Mark Shropshire - [shrop](https://www.drupal.org/u/shrop)
- Stephen Lucero - [slucero](https://www.drupal.org/u/slucero)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment