Something that constantly comes up for me while working on a DotNetNuke Site as a designer, is making the site look good, being friendly toward the Search Engines and yet still keeping all of the dynamic capabilities of DNN, which is why we use it, instead of straight HTML, right? I have come across a few little tricks in which I will share in my next few posts.
One of my favorites is also very simple. It replaces the default title of a container. Doing this will remove a decent amount of the code bloat around the title, leaving it open to place directly into a header element of your choice. This also leaves it open to more easly target your title with CSS, without having other classes and elements getting in the way.
To do this, simply follow these steps:
Note: You will need to edit the ascx file. If you use the HTML method of skinning, you will need to create your skin as normal, install it and edit the ascx file that it created.
- Locate and open your container.ascx file that you wish to change.
For Example: /portals/0/containers/mydesign/container.ascx
- Remove the following piece of code
<dnn:TITLE runat="server" id="dnnTITLE" />
- Add the following code. (I place mine at the top of the document, directly below the register tags.)
<dnn:title runat="server" id="dnnTitle" visible="false" />
<%
Dim ModuleTitle As String = DotNetNuke.UI.Containers.Container.GetPortalModuleBase(dnnTITLE)
.ModuleConfiguration.ModuleTitle()
%>
- Place this in your header tag
<%= ModuleTitle %>
such as <h2><%= ModuleTitle %></h2>
- Save the file back to the original location.
This technique removes the following span, which would have prevented you from wrapping your title in a compliant header tag:
<span id="dnn_ctr2243_dnnTITLE_lblTitle"></span>
I used to put the header tag in the title of the module by going to the module settings and wrapping the module title in the header tags. This is a much cleaner and automatic approach. I usually make more than one container based on which header tag I need to use. Such as, seperate h1, h2 and h3 containers. Then, I can just change my container to change the header tag.
I hope this is helpful.
Resources: How to aviod the Span in the dnn:TITLE