Disable blocks based on theme
Permalink
I'm working on a mobile theme for a site that has a number of add-on blocks (like tabbed content, slideshows, event calendars, etc). These blocks have .js and .css files in their directories that gets loaded automatically thanks to C5's wonderful system of local overrides.
What I'm trying to figure out is how to disable the .js and .css code that's part of those blocks from loading. I've loaded the mobile theme switcher, and that works well for disabling side bars, but I have blocks loading in my "main" area that's still loading a bunch of .css and .js, adding considerably to the download size.
I'm hoping to accomplish this without having to edit individual block overrides. Any thoughts?
What I'm trying to figure out is how to disable the .js and .css code that's part of those blocks from loading. I've loaded the mobile theme switcher, and that works well for disabling side bars, but I have blocks loading in my "main" area that's still loading a bunch of .css and .js, adding considerably to the download size.
I'm hoping to accomplish this without having to edit individual block overrides. Any thoughts?
Do you only want to prevent output of these js and css files in some situations (like only when viewing the mobile site), or always? If always, I think you should just delete the js and css files. Otherwise... C5 automatically loads "view.js" and "view.css" files and any .js files in the /js/ directory and any .css files in the /css/ directory (of each block). So... you could delete all of those so they aren't loaded automatically, then add some code to the block's controller.php file that conditionally loads them depending on the theme that's being shown (in the on_page_view() function).
jordanlev,
you are exactly correct. I'm trying to prevent the loading of the .css and .js files that auto-load with block templates for a mobile version of a site. In some cases, I want to prevent an entire type of block from loading (like a slideshow or an image block) in the mobile version.
I already am using your technique, but I was looking for a method to implement this site-wide, rather than edit a number of blocks/templates. I've been digging through the code to see exactly where c5 calls the extra files, no luck yet.
I'm trying to prevent those files from loading for two reasons: downloaded file size (& speed), and existing .js sometimes conflicts or doesn't run correctly in some mobile browsers.
Sherm
you are exactly correct. I'm trying to prevent the loading of the .css and .js files that auto-load with block templates for a mobile version of a site. In some cases, I want to prevent an entire type of block from loading (like a slideshow or an image block) in the mobile version.
I already am using your technique, but I was looking for a method to implement this site-wide, rather than edit a number of blocks/templates. I've been digging through the code to see exactly where c5 calls the extra files, no luck yet.
I'm trying to prevent those files from loading for two reasons: downloaded file size (& speed), and existing .js sometimes conflicts or doesn't run correctly in some mobile browsers.
Sherm
Sorry, I have no idea how this could be done :(
I'm trying to follow the code to see how C5 loads .css and .js files automatically.
Also interested in stopping the view.css file from being output to the browser. Anyone figure this one out?
Any help on this?