Add field in config to attach library

Created on 1 February 2024, 11 months ago
Updated 14 July 2024, 5 months ago

Good morning,
Sometimes we need to attach JS and CSS libraries in a block, can you add extra field in block configuration, that we can add separate library by ,
Thanks

Feature request
Status

Active

Version

1.0

Component

User interface

Created by

🇫🇷France lazzyvn paris

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @lazzyvn
  • 🇮🇳India ravi kant Jaipur

    It will very helpful if we can get list of all libraries in block config page and select library according requirement.

    But alternate solution may be as -
    1. Use classes and detect class in template file and attach library
    2. Create select list and attache library by conditional checking in block type template file.

  • 🇫🇷France lazzyvn paris

    Do it simple like https://www.drupal.org/project/views_attach_library
    (This works with block views)
    Sometimes I just need to add my custom library in a block for example: my_custom_module/my_lib1, my_custom_module/my_lib2
    it will add
    $element['#attached']['library'][] = 'my_custom_module/my_lib1';
    $element['#attached']['library'][] = 'my_custom_module/my_lib2';
    my custom library will add custom css and custom js. it will be very useful

    Can you add me to maintainer with full right, pls? I will add this feature to version 2.x

  • 🇫🇷France lazzyvn paris

    I make add library patch for 1.x. please add to 2.x

Production build 0.71.5 2024