Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save h1ldebrand/d87d91d003b1819ad1a86caca0889d53 to your computer and use it in GitHub Desktop.
Save h1ldebrand/d87d91d003b1819ad1a86caca0889d53 to your computer and use it in GitHub Desktop.
получить значение поля в блоке и передать его в js
function naturetour_page_attachments_alter(array &$attachments){
$uuid = \Drupal\block\Entity\Block::load('usefull')->getPlugin()->getDerivativeId();
$block_content = \Drupal::service('entity.repository')->loadEntityByUuid('block_content', $uuid);
if ($block_content) {
$field_value = $block_content->field_something_item->value;
$attachments['#attached']['drupalSettings']['naturetour']['custom']['something_item'] = $field_value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment