Disable block automatic inclusion of css/js in page header
Permalink
I have a block which requires multiple css and js files, and having dropped them into the block's css and js folders, they're included in the page header automatically. Great. Except in this case, some of them don't play nicely when the page is in edit mode, making it nearly impossible to edit. I have lost the will to live trying to figure out why and reckon the easiest thing is to not include them when editing.
Does anybody know how to disable the automatic inclusion of css and js files from the block folder in the page header?
I have worked around the issue by including files manually using addHeaderItem in the on_page_view method, but it seems rather ugly to have to do this. I'd much rather override the method that includes them if the page is in edit mode.
Does anybody know how to disable the automatic inclusion of css and js files from the block folder in the page header?
I have worked around the issue by including files manually using addHeaderItem in the on_page_view method, but it seems rather ugly to have to do this. I'd much rather override the method that includes them if the page is in edit mode.
The only way I know of to do this is via the on_page_view method. I don't think it's ugly -- I actually prefer this method because it is more explicit.
Agreed, it is more explicit, but it just seems like unnecessary code. Perhaps a touch too much hubris on my part. Thanks anyway.
Andrew says version 5.7 will have better asset management, in the meanwhile you'd use this approach:http://www.adrikodde.nl/blog/2013/concrete-removeheaderitem/...
It works well, and I think it's better than overriding block controllers.
It works well, and I think it's better than overriding block controllers.