As some of you might have noticed, removing style-sheets with the StyleHelper Skin Object does not work any more since DotNetNuke 6.1 (all other functionality still works BTW).
Here are my considerations on this issue.
It's not an easy problem to solve, feel free to leave your comments or suggestions.
I already investigated the cause of this, but as Ian Robinson was in the Netherlands last month for a DNN meeting, that was a good opportunity to discuss the issues I have.
Ian developed the new Client Resouce Management in DNN 6.1.
The Client Resource Management in DNN 6.1 allows combining CSS and JS files into one file and compressing them, this a great new functionality, but it does break unloading style sheets with our skin object.
To make combining style-sheets possible the way they are loaded has changed in DotNetNuke 6.1.
This is the reason why unloading style sheets with our Stylehelper skin object does not work any more.
Why unloading style sheets stopped working
In previous versions of DotNetNuke all style sheets were loaded if the corresponding control loaded. So as soon as a module loaded it's style sheet was injected, same for the skin and skin.css.
In Dotnetnuke 6.1 this had to be changed as the style sheets should first be collected and then combined at the end. For that the moment the style sheets are actually injected has changed, they are now injected at the end of the page render process.
Unfortunately this is after the code of the style helper skin object is executed.
So there is no way to remove individual style sheets any more with the code executed by the Style Helper skin object as they are not injected yet when it executes.
(BTW, this is also the reason I could not remove most JavaScript files in DNN 5, they were injected after the Style Helper executes)
Solutions for unloading style sheets?
In DotNetNuke 6 there are 2 new controls in Default.aspx, that are used to inject the Style sheets and Java-scripts.
<asp:PlaceHolder runat="server" ID="ClientDependencyHeadCss"></asp:PlaceHolder>
<asp:PlaceHolder runat="server" ID="ClientDependencyHeadJs"></asp:PlaceHolder>
In essence DotNetNuke first collects all the Stylesheets and then at the end injects them in the ClientDependencyHeadCss control, even if you don't set the style-sheet combination / compression to on.
When the Stylehelper code runs this control is empty, the only option I have at that moment is to disable the ClientDependencyHeadCss control, which "unloads" all style-sheets.
So what are the options?
A. Use an HTTP Module
With an HTTP module (nothing like a DNN Module) I can access the generated HTML and make changes just before the result is sent to the client.
Although this seems nice, it has issues to.
It would prevent you from using the styls heet combining & compression in DNN 6.1 as at that moment in time the combined style sheet is already injected.
As that's one of the best enhancements of DNN 6.1, I don't see this as a valid solution.
B. Create our own Client Resource Management provider
The new Client Resource Management is provider based, so in principle I could create a 40Fingers version and overwrite the default behaviour.
The disadvantage is that I would have to keep up with all new functionality added to the DNN version.
C. Add removing stylesheets to the Core Client Resource Management
IMO the best option would be if the Client Resource Management would allow removing style sheets and JavaScript files already registered.
I discussed this with Ian Robinson and he agreed it would be good if the CRM would allow unloading.
In fact he had already created an issue for this: http://support.dotnetnuke.com/issue/ViewIssue.aspx?id=19024&PROJID=2
If that would be added the style helper skin object could call this new function to remove any style sheet you would want to be removed and then we could also finally remove JavaScript from the source.
I think it would not be smart to create a new provider at this time as there are plans to correct this in the core.
BTW AFAIK, Ian is not the one to decide if this change is going to be made.
So don't blame him it this is not changed (blame me for not lobbying enough ;-)
Solution
A. I'm going to lobby for adding unloading resources to the CRM in the core.
If the change is incorporated I'll add support to the style helper skin object.
If the change is rejected I'll consider creating a spin-off of the provider.
2. I'm going to add an option to remove all style sheets, as that's all I can currently do.
This does mean you would have to manually add the style sheets you do want to load, using the Style Helper skin object.
It's a bit of work on the skin, but I guess most people are using the Stylehelper skin object to load only skin.css and unload the rest.
Feel free to leave your comment, if you have any remarks of suggestions...
Timo Breumelhof