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

Workflow of WordPress project in a team with Git

1. We should not push any Wordpress core folders or files to github. 2. Only push custom theme and custom plugin into github. 3. So, in this...