DotNetNuke - 标题,内容和页脚 [英] DotNetNuke - Header, Content and Footer

查看:120
本文介绍了DotNetNuke - 标题,内容和页脚的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有什么办法像WordPress一样,创建一个header.php,theme-file.php和footer.php,然后使用钩子将它们组合起来?对我来说,仍然复制皮肤文件似乎很疯狂,特别是当您需要对页眉或页脚的内容进行细微更改时。



非常感谢

解决方案

皮肤只是一个ascx控件,所以您可以像封装任何其他WebForms视图一样封装它的一部分。您可以将页眉/页脚内容放入他们自己的ascx文件中,然后将它们包含在皮肤中。唯一会遇到问题的地方是我不认为DNN支持在单独的控件中使用窗格;一切都应该是公平的游戏。



你需要将它们放在一个单独的目录中,这样它们才不会被DNN看作其他皮肤。

  -MySkin 
- 控件
--- Header.ascx
--- Footer.ascx
--Home.ascx
--Home.doctype.xml
--Interior.ascx
--Interior.doctype.xml



然后,在皮肤中,通过在标题中注册控件来包含控件:

 <%@ Register TagPrefix =myskinTagName =HeaderSrc =Controls / Header.ascx%> 
<%@ Register TagPrefix =myskinTagName =FooterSrc =Controls / Footer.ascx%>

并通过控制语法包含它:

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

控件不会自动从皮肤访问任何上下文,所以如果您需要使用 SkinPath PortalId 或类似的东西,您需要手动将它传递给控件。在控件中,定义一个属性来接收值(使用< script runat =server> 部分编写代码[set the 语言控件中的属性为此C#]]:

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

然后在皮肤中传递值:

 < myskin:Header runat =serverSkinPath =<%#SkinPath%> /> 


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

解决方案

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 %>" />

这篇关于DotNetNuke - 标题,内容和页脚的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆