I am looking for a standardized way to add content such as content types into an installation profile.

Suppose we exported the JSON for REST Content and want to import them during installation. I have created a custom profile, and it works. Now I need to import the default content. For that, I used the Default Content for D8 module.

So, I created the content folder in profile/custom_module/content/node/my_file.json.

Also, I am using a minimal profile installation with the following hook_install() implementation.

function mymodule_profile_install() {
  include_once DRUPAL_ROOT . '/core/profiles/minimal/minimal.install';

In the info.yml file, there is only one module dependency.

- default_content

When I run install.php, my default content is not installed. Also, when I checked admin/module page, this module is enabled, but the basic core modules aren't, even if they are listed in the minimal.info.yml file.

I don't understand what I am missing.

Why isn't my default content installed?

  • Please edit the question to provide details about the problem, what you’ve tried to solve it, and exactly what’s wrong with the result. At the moment it’s really not clear what you could be asking – Clive Jan 29 '18 at 10:52
  • Updated my question. Kindly help. – latikas Jan 29 '18 at 13:01
  • 1
    If you don’t have the node module installed, what are you hoping to happen when you provide a node to be imported? Also the yaml as you’ve posted it is invalid - you need to fix that up and clear the cache before continuing – Clive Jan 29 '18 at 17:57

The issues I see are three:

  1. As pointed out from Clive, the YAML file is invalid. The second line needs to be indented.

      - default_content

    You can use the content of minimal.info.yaml as guide to write the .info.yml file of your installation profile.

  2. An installation profile doesn't inhered its dependencies from another installation profile.

  3. The Default Content for D8 module doesn't automatically handle the dependencies necessary to create the content entities imported with it.

This means that you need to:

  • Fix the indentation of the .info.yml file for the installation profile
  • Add all the necessary dependencies

From the question, I take the installation profile is just creating nodes or content types. In that case, the .info.yml file would be fine if it contains the following dependencies.

  - node
  - default_content

As side note, instead of including the core/profiles/minimal/minimal.install file, I would rather copy the code from minimal_install().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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