We still need some way to provide assets (css, js, etc) related to the view, right? If this is implemented, I did not see where it was at. Thanks
We still need some way to provide assets (css, js, etc) related to the view, right? If this is implemented, I did not see where it was at. Thanks
Comments
Comment #1
Caseledde commentedThe core caching mechanism is aware of related attachements.
There is an attribute for renderable arrays called '#attached'. This is an array with needed js, css and/or libraries. It will be cached together with the rendered output.
The responsible funktion drupal_process_attached() will be called everytime, regardless of whether the display is cached or not. This function will call drupal_add_js() and similar functions.
Comment #2
fmizzell commentedI was not aware of #attached. thanks
Comment #4
ey commentedSorry for re-opening the issue but I couldn't get it working on my project. I had some
drupal_add_jsanddrupal_add_csscalls in mytemplate_preprocess_nodeimplementation.I've updated those to use
#attachedattribute instead, they are working for the first page load as expected, but after the view is cached, the css and js files won't load.Am I adding them to a wrong place?
My current implementation:
Thanks.
Comment #5
Caseledde commentedHi,
the preprocess seems a bit late. You may tryout hook_node_view_alter() or hook_entity_view_alter() instead.
Comment #6
ey commentedHi Caseledde, thanks a lot, it worked :)