Question

Some days ago I've exported and imported a full configuration with drush cex and drush cim.

What are the steps to export 1 paragraph type including the fields, form settings, display settings etc ...

I'm using a multisite, so it would be great to copy them from one site to the other sites within the multisite.

Can I:

  1. drush cex site 1
  2. copy exported .yml files to other site in folder (sites/site1.multisite.com/files/config_HASH/sync)
  3. Delete all .yml files except those needed for the import of my paragraph type?

I guess there are better methods to establish this?

Was it helpful?

Solution

That's exactly what the Features module is for. Syncing partial config across multi-site instances.

The features module enables the capture and management of features in Drupal. A feature is a collection of Drupal entities which taken together satisfy a certain use-case.

Features provides a UI and API for taking different site building components from modules with exportables and bundling them together in a single feature module. A feature module is like any other Drupal module except that it contains additional information in its info file so that configuration can be checked, updated, or reverted programmatically.

That means you would create a feature on your main multi-site instance which contains the paragraph type. Have it placed inside the modules/features/ folder. Related config will be added automatically. You then enable the feature (which basically is just another module) in another multi-site instance. The config will be imported into the database. On both multi-site instances you then export config as usual. Because every multi-site instance still is managed from its own config. Which then also contains the synced paragraphs config.

As soon as you add another field to the paragraph type on either multi-site instance Features will recognise the changes. You then can recreate your paragraph feature and import the changes on another multi-site instance (into the database). Finally, on both sites again export config as usual (which then also contains the paragraph types you've synced via Features). Features enables you to keep track of changes to a feature via built-in diffing, which after you recreated the feature (partial config gets exported) can be synced into the database on other multi-site instances again.

Of course Features also comes with a set of Drush commands to make your live easier.

OTHER TIPS

Best way to do this is make custom modules and add the specific yml files to config/install. This way you can just enable the module on other websites.

A good way of working could be a custom module named custom_paragraphs with a .info file and a modules folder. Within this module all your submodules per paragraph type.

  • custom_paragraphs
    • custom_paragraphs.info.yml
    • modules
      • custom_paragraphs_two_column
        • custom_paragraphs_two_column.info (add dependencies here!)
        • config
          • install
            • (all the yaml files here)
      • custom_paragraphs_slider
        • ...

Update a module by using:

drush config-import --partial --source=modules/custom/custom_paragraphs/modules/custom_paragraphs_two_column/config/install
Licensed under: CC-BY-SA with attribution
Not affiliated with drupal.stackexchange
scroll top