Skip to main content
Refined question
Source Link
leymannx
  • 18.8k
  • 6
  • 72
  • 126

Move blocks How can I programmatically in Drupal 8place blocks?

I'm migrating a Drupal 7 site to Drupal 8.

The old site uses $ drush block_configure (available in drush_extrasDrush extras) to put blocks in regions while deploying, as well as $ drush block-disable to remove unwanted blocks. Unfortunately, drush_extrasDrush extras is no longer available for Drush 8, which seems to be the first version supporting Drupal 8.

The site will be deployed multiple times by multiple people, so adjusting region settings manually in admin view is not a solution. Everything needs to be done in an Ansible playbook so it can be passed on easily.

It seems that configuration management can be used to move blocks, but this would require all the environments to have up-to-date copies of a master database. While this is not impossible, it does feel like a hassle and a possible security risk. The developers don't really need to have all production data in their dev envsenvironments, and I wouldn't want to put production data on servers using developmental (and possibly vulnerable) code.

Twig Tweak seems to have an option to render a block anywhere regardless of regions. However, if I hardcode all blocks on templates, admins can no longer use admin block management.

Would it be possible to write a custom module and use block alter functions to set regions on blocks created by core modules? Are there any examples of this?

Are there more ways I'm not aware of? What is the best practice?

Move blocks programmatically in Drupal 8

I'm migrating a Drupal 7 site to Drupal 8.

The old site uses drush block_configure (available in drush_extras) to put blocks in regions while deploying, as well as drush block-disable to remove unwanted blocks. Unfortunately, drush_extras is no longer available for Drush 8, which seems to be the first version supporting Drupal 8.

The site will be deployed multiple times by multiple people, so adjusting region settings manually in admin view is not a solution. Everything needs to be done in an Ansible playbook so it can be passed on easily.

It seems that configuration management can be used to move blocks, but this would require all the environments to have up-to-date copies of a master database. While this is not impossible, it does feel like a hassle and a possible security risk. The developers don't really need to have all production data in their dev envs, and I wouldn't want to put production data on servers using developmental (and possibly vulnerable) code.

Twig Tweak seems to have an option to render a block anywhere regardless of regions. However, if I hardcode all blocks on templates, admins can no longer use admin block management.

Would it be possible to write a custom module and use block alter functions to set regions on blocks created by core modules? Are there any examples of this?

Are there more ways I'm not aware of? What is the best practice?

How can I programmatically place blocks?

I'm migrating a Drupal 7 site to Drupal 8.

The old site uses $ drush block_configure (available in Drush extras) to put blocks in regions while deploying, as well as $ drush block-disable to remove unwanted blocks. Unfortunately, Drush extras is no longer available for Drush 8, which seems to be the first version supporting Drupal 8.

The site will be deployed multiple times by multiple people, so adjusting region settings manually in admin view is not a solution. Everything needs to be done in an Ansible playbook so it can be passed on easily.

It seems that configuration management can be used to move blocks, but this would require all the environments to have up-to-date copies of a master database. While this is not impossible, it does feel like a hassle and a possible security risk. The developers don't really need to have all production data in their dev environments, and I wouldn't want to put production data on servers using developmental (and possibly vulnerable) code.

Twig Tweak seems to have an option to render a block anywhere regardless of regions. However, if I hardcode all blocks on templates, admins can no longer use admin block management.

Would it be possible to write a custom module and use block alter functions to set regions on blocks created by core modules? Are there any examples of this?

Are there more ways I'm not aware of? What is the best practice?

Bumped by Community user
Source Link
Meepu
  • 31
  • 3

Move blocks programmatically in Drupal 8

I'm migrating a Drupal 7 site to Drupal 8.

The old site uses drush block_configure (available in drush_extras) to put blocks in regions while deploying, as well as drush block-disable to remove unwanted blocks. Unfortunately, drush_extras is no longer available for Drush 8, which seems to be the first version supporting Drupal 8.

The site will be deployed multiple times by multiple people, so adjusting region settings manually in admin view is not a solution. Everything needs to be done in an Ansible playbook so it can be passed on easily.

It seems that configuration management can be used to move blocks, but this would require all the environments to have up-to-date copies of a master database. While this is not impossible, it does feel like a hassle and a possible security risk. The developers don't really need to have all production data in their dev envs, and I wouldn't want to put production data on servers using developmental (and possibly vulnerable) code.

Twig Tweak seems to have an option to render a block anywhere regardless of regions. However, if I hardcode all blocks on templates, admins can no longer use admin block management.

Would it be possible to write a custom module and use block alter functions to set regions on blocks created by core modules? Are there any examples of this?

Are there more ways I'm not aware of? What is the best practice?