function floating_block_page_attachments in Floating block 8
Implements hook_page_attachments();
File
- ./
floating_block.module, line 12 - The floating_block module allows parts of the site to stay on the page when scrolling.
Code
function floating_block_page_attachments(array &$attachments) {
$floating_blocks = \Drupal::config('floating_block.settings')
->get('blocks');
// Only load the javascript if floating blocks have been configured.
if (is_array($floating_blocks) && count($floating_blocks)) {
$attachments['#attached']['library'][] = 'floating_block/floating_block';
$attachments['#attached']['drupalSettings']['floatingBlock']['blocks'] = $floating_blocks;
}
}