![]() Let’s understand the application of this module via an example.Ĭonsider a custom module called ‘abc’ and this module has a library called ‘abc-js’ and this library has one CSS(abc.css) and two JS(abc1.js, abc2.js) files. To add the library in view follow the below steps: Installation is as simple as copying the module into your 'modules' contrib directory and then enabling the module. We can upload single as well as multiple libraries just by declaring the libraries name in the UI textfield. The module provides a simple UI option in all view pages and blocks. To implement this, I attached a CSS or JS library to a view in Drupal 8 via a custom module such that, wherever the view is displayed on a site, the custom CSS and JS file from my module were attached automatically. Instead of writing custom coding to attach library in views, this module provides you simple configuration UI in views UI. ![]() Add single as well as multiple libraries in views.Easily attach libraries to any view’s page or block.| Benefits of Views Attach Library module It provides a simple UI option in the views where a user has to simply mention the libraries name. Views Attach Library module is designed to attach JS and CSS library in views, by merely mentioning the library name. Let's explore this recently contributed module by QED42, the 'Views Attach Library'. Previously we used the hook_views_pre_render() hook method to attach a library in the view. Thus to attach CSS or JS assets to views, nodes, etc., Drupal's #attached functionality had to be applied to 'attach' assets (like CSS and JS) to rendered elements on the page. The drupal_add_css(), drupal_add_js(), and drupal_add_library() were removed from Drupal 8 for various reasons.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |