Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DotNetNuke - Header, Content and Footer

Is there any way, like one does with WordPress, to create a header.php, theme-file.php and footer.php and then combine them using hooks? It seems crazy to me to still duplicate skin files especially when you need to make minor changes to the content of either a header or footer.

Many thanks

like image 595
SixfootJames Avatar asked May 09 '12 09:05

SixfootJames


1 Answers

A skin is just an ascx control, so you can encapsulate parts of it just like you would any other WebForms view. You can put the header/footer content into their own ascx file, and then just include them in the skin. The only place you'll run into an issue with this is that I don't think DNN supports having panes in separate controls; everything else should be fair game.

You'll want to put them in a separate directory, so that they aren't seen as other skins by DNN.

-MySkin
--Controls
---Header.ascx
---Footer.ascx
--Home.ascx
--Home.doctype.xml
--Interior.ascx
--Interior.doctype.xml

Then, in the skins, include the controls by registering them in the header:

<%@ Register TagPrefix="myskin" TagName="Header" Src="Controls/Header.ascx" %>
<%@ Register TagPrefix="myskin" TagName="Footer" Src="Controls/Footer.ascx" %>

And include it via the control syntax:

<myskin:Header runat="server" />
....
<myskin:Footer runat="server" />

The control won't automatically have access to any context from the skin, so if you need to use SkinPath or PortalId or anything like that, you'll need to pass it through to the control manually. In the control, define a property to receive the value (using a <script runat="server"> section to write code [set the Language attribute in the control to C# for this]):

<script runat="server">
public string SkinPath { get; set; }
</script>

Then pass the value in the skin:

<myskin:Header runat="server" SkinPath="<%# SkinPath %>" />
like image 83
bdukes Avatar answered Sep 21 '22 14:09

bdukes