-
-
Save brunodbo/ff8f4727a2b7ed4c1cfdf91156f0c098 to your computer and use it in GitHub Desktop.
Attach a CSS or JS library to a View in Drupal 8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
custom_view: | |
css: | |
component: | |
css/custom_view.css: {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_views_pre_render(). | |
*/ | |
function custom_views_pre_render(ViewExecutable $view) { | |
if (isset($view) && ($view->storage->id() == 'my_view')) { | |
$view->element['#attached']['library'][] = 'custom/custom_view'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment