IMG-LOGO

How to create a simple skin in DNN?

andy - 14 May, 2016 10769 Views 7 Comment

So how does the skin template works in DNN? DNN supports multiple template or skins. Each individual page can have their own skin template or set pre-default skin. The DNN skins are located under portals folder. There are two folders name available, one is _default folder name and the other one is 0 folder name. The _default folder represent the shared folders that can be accessed by all portals. While the 0 portal name is exclusively can be used by a specific portal only which is in this case is the portal that has a portal ID equals to 0.

The following screenshot of the DNN structure folder below is viewed using Visual Studio.

DNN Folder structure

We start the example of skinning by creating a really simple template in html. We will have the following example template structures consist of a navigation, content body and a footer.

Simple skin html template in DNN

This will be the sample of the html code.

<!DOCTYPE html>
<html lang="en">
<head></head>
<body>
	<style>
		html, body,form{
			margin:0;
			padding:0;
			height:100%;
			font-family:Arial;
		}
		
		#container{
			margin:0 auto;
			text-align:left;
			min-height: 100%;
			height: auto !important;
			height: 100%;
			margin-bottom:-50px;
		}
		
		nav{
			background:#000;
			height:50px;
			line-height:50px;
			margin-bottom:10px;
		}
		
		nav ul, nav ul li{
			margin:0;
			padding:0;
			list-style:none;
		}
		
		nav ul li{
			float:left;
			margin:0 10px;
		}
		
		nav ul li a{
			color:#fff;
			text-decoration:none;
			text-transform:uppercase;
		}
		
		#left-column{
			float:left;
			width:23%;
			margin-left:2%;
		}
		
		#right-column{
			float:right;
			width:70%;
			margin-right:2%;
		}
		
		.clear-footer{
			height:50px;
			clear:both;
		}
		
		footer{
			height:50px;
			line-height:50px;
			background:#000;
			color:#fff;
			text-align:center;
		}
	</style>
	<div id="container">
		<nav>
			<ul>
				<li><a href="#">Home</a></li>
				<li><a href="#">Products</a></li>
				<li><a href="#">About Us</a></li>
				<li><a href="#">Contact Us</a></li>
			</ul>
		</nav>
		<div id="body-content">
			<div id="left-column">
				left content goes here...
			</div>
			<div id="right-column">
				right content goes here...
			</div>
		</div>
		<div class="clear-footer"></div>
	</div>
	<footer>
		Copyright mysite
	</footer>
</body>
</html>

We create the simple skin template in the Portal 0 folder. This is the correct place to create your first skin DNN. If have to share your skin for multiple websites, you can place the skin template into the _default folder instead. See the structure of folder I just created below. It is named ByTutorial_SkinTemplate.

Create skin template in 0 folder

To help you save time, we can just copy the sample skin template from the _default folder. In this example, we copy the template name from Gravity folder. What we need are the skin.css, 2-col.ascx, simple folder which is the contains navigation script and image preview for 2-col.jpg, this is optional. If you do not want to offer any preview image, you can omit this one.

Copy skin gravity skin template in DNN

Let's open the 2-col.ascx file and modify the html according to our skin. One of the most important thing you need to understand is, the DNN skin always required a server tag named ContentPane and if you do not have this, it will result an error when you try to load this screen. Basically you need this code sitting somewhere in your skin template. The ContentPane text is not case sensitive so it can be lowercase if you want.

<div id="ContentPane" runat="server"></div>

Here is the new template based on the html skin template we create. We remove all html tags that are not used based on our skin template.

<%@ Control language="vb" AutoEventWireup="false" Explicit="True" Inherits="DotNetNuke.UI.Skins.Skin" %>
<%@ Register TagPrefix="dnn" TagName="LANGUAGE" Src="~/Admin/Skins/Language.ascx" %>
<%@ Register TagPrefix="dnn" TagName="LOGO" Src="~/Admin/Skins/Logo.ascx" %>
<%@ Register TagPrefix="dnn" TagName="SEARCH" Src="~/Admin/Skins/Search.ascx" %>
<%@ Register TagPrefix="dnn" TagName="BREADCRUMB" Src="~/Admin/Skins/BreadCrumb.ascx" %>
<%@ Register TagPrefix="dnn" TagName="USER" Src="~/Admin/Skins/User.ascx" %>
<%@ Register TagPrefix="dnn" TagName="LOGIN" Src="~/Admin/Skins/Login.ascx" %>
<%@ Register TagPrefix="dnn" TagName="PRIVACY" Src="~/Admin/Skins/Privacy.ascx" %>
<%@ Register TagPrefix="dnn" TagName="TERMS" Src="~/Admin/Skins/Terms.ascx" %>
<%@ Register TagPrefix="dnn" TagName="COPYRIGHT" Src="~/Admin/Skins/Copyright.ascx" %>
<%@ Register TagPrefix="dnn" TagName="LINKTOMOBILE" Src="~/Admin/Skins/LinkToMobileSite.ascx" %>
<%@ Register TagPrefix="dnn" TagName="MENU" src="~/DesktopModules/DDRMenu/Menu.ascx" %>
<div id="container">
	<dnn:MENU MenuStyle="Simple" runat="server"></dnn:MENU>
	<div id="body-content">
		<div id="left-column">
			<div id="leftpane" runat="server"></div>
		</div>
		<div id="right-column">
			<div id="contentpane" runat="server"></div>
		</div>
	</div>
	<div class="clear-footer"></div>
</div>
<footer>
	<dnn:COPYRIGHT ID="dnnCopyright" runat="server" />
</footer>

In order for DNN to understand where to place the module you will need to create a html tag as server control. Usually it is a div tag, but it is not limited to this, it can be td row or span if you prefer. For example, we have two columns in our skin template. One is for the left content and the other one is for the right content. As we place contentpane in the right content, we need another server control to be placed in the left content. Therefore in this case we create the server pane named leftpane. The DNN will now recognize there are two panes available for the system to insert the module. See below image on how DNN detects the panes available to use.

Module pane selector in DNN

The next part is to modify the navigation template file, let's open the SimpleTokens.txt file. We need to match it accordingly to our html navigation. You can leave the script for the navigation as it is. So the only changes are the couple top lines code.

<nav>
<ul>
[*>NODE]
</ul>

The last step is to copy our style into the skin.css file. Simple open the skin.css file and copy and paste the style from our html. Just to let you know by default each template will use the style called skin.css, so this is a required file.

Once everything has already been completed, we can create a simple page and start set the page use our first skin template. The following is the result of the skin template we just create.

First skin template in DNN

If you see above image, it seems that our style we create in html doesn't look the same with the result. This is because it was overwritten by default.css loaded by DNN. What you need to do is to overwrite the style again. Hope this quick tutorial helps. If you have any question about this, feel free to post your comment below.

Comments

azz
12 Jan, 2017
thanks for the tutorial I tried it and succeeded, but I want to use "Mega2DNN" menu style in this skin can you tell me how to alter the "simple" menu
andy
06 Feb, 2017
What you can do is to look for menu word in the skin file and remove that coding and open any default skin that use Mega2DNN menu and replace it. Make sure you include any part of Mega2DNN required files at the top of the code. It should be included I believe by default but just double check it.
Salam
08 Mar, 2018
Andy nice and simple tutorial, I am a little bit confused as I am new to DNN. You remove the following section from the template then, in the last snapshot I can see those 4 elements in the menu. Where this section should go (in which file those links should go)? I followed your tutorial, getting 2 items in the menu, Home and the name of the page itself. Is it possible to share the finale files in a download Thanks in advance
andy
08 Mar, 2018
Hi Salam, Unfortunately, I didn't save the actual files. That menu is actually being replaced by this.
<dnn:MENU MenuStyle="Simple" runat="server"></dnn:MENU>
Just have a look a sample of default DNN skin. All the layout for the menu specified in the simpletokens.txt Let me know if you need further help.
Salam
09 Mar, 2018
OK and thanks for your response, just made a test, with this dnn:Menu, whenever you add a page, the name of the page is added to the menu as a menu item. In fact, I have a DNN 9.1 setup and there is no gravity skinn I have only Xicillion skin. I placed menuTokens.txt in the "Simple" directory as there is no simpletokens.txt in my dnn folder is it something related to versions?
Salam
09 Mar, 2018
Another question as I am new to DNN, the menu is displayed on the left hand site, how it can be centered or sent to right?
andy
09 Mar, 2018
Hi Salam, In the css code, look for the following code:
nav ul li{
   float:left;
   margin:0 10px;
}
Change the float to the right if you want to place it on the right side. Or set the text-align to center. If you want to center the menu in the center position you have to set a specific width for the menu.
andy
09 Mar, 2018
Hi Salam, Yes, I might have used the earlier version than version 9. the concept would be pretty similar. I would say start playing with their default DNN skin first to try out.
Write Comment
0 characters entered. Maximum characters allowed are 1000 characters.

Related Blogs

How to change copyright text in DNN?

In this article, I am going to show you how to change the copyright text in DNN. Usually, a copyright text is located under the footer of the site template.

Related Tutorials

Create your first DNN module extension

In this tutorial you will learn how to create your first DNN module This will be a basic module that will display Hello World You will learn also how to get a module setting and save the value into module ...

How to Install DotNetNuke?

This tutorial would be a good start for DNN newbie I have attached screenshots to help you on how to install the DotNetNuke step by step You can try this in your local computer first before installing it on live ...

What is DNN?

DNN is an open source web content management system based on Microsoft Net It was written in VB Net but it has been fully migrated to C since version 6 0 There are three versions available for DNN which are ...

How to install module extension in DotNetNuke?

What is actually a module extension in DNN A module extension can be considered as plugin program that you can install on your site Just imagine you have a car and you want to add a new sound system to ...

Manage Pages in DNN

Learn how to create and manage pages in DNN. To manage a page in DNN you must have an administrator role assigned on your account. The way how the DNN page work is based on single default.aspx only.