Friday, May 28, 2021

Drupal 9 - Read custom block body content

Drupal 9 - Read custom block body content:

$block = \Drupal\block\Entity\Block::load('block_machine_name');
if ($block) {
$blockuuid = $block->getPlugin()->getDerivativeId();
  $blockContent = \Drupal::service('entity.repository')
->loadEntityByUuid('block_content'$blockuuid);
  $vsf_form_message = $blockContent->get('body')->value;
}

Happy coding!

No comments:

Post a Comment

Change priority of dual boot OS

Change priority of dual boot OS  (Windows and Linux): Go to your Linux OS, install Grub customizer. Then change priority by up and down arro...