0

My question seems pretty simple but is very important: IS it possible or any solution to backup created block as a module to avoid duplication work, because there are times need to do something similar for multiple times and sites.
Like:

  • Create simple block with social media links, icon and some stable text.
  • Create a view that show five recent content title of custom content type as customized block for several sites.
    and all repetitive and permanent tasks can be done each time.

Thanks for any help and feedback.

1
1

Exporting and importing blocks in Drupal 8 are quite easy (thanks to new configuration system). You don't need to create a module for this. In Drupal 8 configuration is stored in yml files. You can export and import it on the following page:

Administration >> Configuration >> Development >> Synchronize >> (import / export) >> Single item

It works for all kind of blocks except "Custom blocks" because they are actually not a configuration but content like nodes, comments etc. As a workaround you can use Simple block module mentioned above.

Note, that in some cases you also need to export block configuration dependency in a separate yml file. For instance for a block that shows five recent content titles you need to export underlying view and all its dependencies. You may also checkout Features module for some advanced configuration package tools.

0

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.