Reputation: 3002
I have created the Project using DNN. I have written my CSS code in say "main.css". Firstly, I have created the HTML of the Project and then I have integrated it with DNN.
Now, the DNN default.css, skin.css and portal.css is overriding the main.css. I need a way to that when I am logging in through admin then only "default.css, skin.css and portal.css" this CSS should get applied. Otherwise for Normal users it should not get applied..
Simple flow of css to add
Admin User - default.css, skin.css , portal.css and main.css
Normal User - main.css
Hope My question is understandable..
Upvotes: 4
Views: 2483
Reputation: 787
@DamingZhang answer seems to me the more accurate. Another option is to navigate to the file and clear its content. You may want to make a copy of the file first. I didn't.
Upvotes: 0
Reputation: 33
<%@ Register TagPrefix="dnn" Namespace="DotNetNuke.Web.Client.ClientResourceManagement" Assembly="DotNetNuke.Web.Client" %>
<dnn:DnnCssExclude runat="server" Name="dnndefault" />
Put those above in the page template file, like home.ascx, index.ascx. It will remove default.css, can I ask you why are you going to remove it? it will cause an issue when you are trying to add a new module and you probably are not able to drag the module in the admin mode (I'm using DNN9.8)
Upvotes: 2
Reputation: 9
Default.aspx: at first line replace CodeBehind with CodeFile attribute.
in Default.aspx.cs in OnPreRender method add at bottom:
var loader = Page.FindControl("ClientResourceIncludes");
var toRemove = new List<ClientDependencyInclude>();
foreach (ClientDependencyInclude ctl in loader.Controls)
{
if (ctl.FilePath.Contains("/Resources/Search/SearchSkinObjectPreview.css")
|| ctl.FilePath.Contains("/Portals/_default/admin.css"))
toRemove.Add(ctl);
}
}
foreach (var ctl in toRemove)
loader.Controls.Remove(ctl);
all error checking skipped for clarity
Upvotes: 0
Reputation: 131
disable or remove the default.css, skin.css and portal.css in DNN for normal Users
For DNN 7 :- Disable/Remove unwanted (default) css files to be loaded in DotNetNuke (DNN)
For DNN 8:-
<script type="text/javascript">
$(document).ready(function () {
if ($('#ControlBar_ControlPanel').length == 0) {
$('head link[href*="/Resources/Shared/stylesheets/dnndefault/7.0.0/default.css"]').remove();
$('head link[href*="/Resources/Shared/stylesheets/dnndefault/8.0.0/default.css"]').remove();
}
});
</script>
Upvotes: 3
Reputation: 8963
Your best bet will probably be to use the StyleHelper SkinObject https://stylehelper.codeplex.com/
Or some modified version of that.
Upvotes: 1
Reputation: 2446
You could use php to add link tags for admin, something like
<?php
if ($_SESSION["pseudo"] = "admin") {
?>
<link rel="stylesheet" type="text/css" href="default.css">
<link rel="stylesheet" type="text/css" href="skin.css">
<link rel="stylesheet" type="text/css" href="portal.css">
<?php
}
?>
<link rel="stylesheet" type="text/css" href="main.css">
Upvotes: -3