如何使用 ContentPlaceHolderId CMS (Umbraco)
我有一个带有 HTML 标签的简单主模板,我想在其中添加页脚和页眉。由于某种原因,它不会同时显示页眉和页脚。我使用 ContentPlaceHolderId 是否错误?它们不应该都是模板吗?
主模板
<asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server">
<head>
</head>
<body>
<asp:ContentPlaceHolder Id="header" runat="server"></asp:ContentPlaceHolder>
<asp:ContentPlaceHolder Id="footer" runat="server"></asp:ContentPlaceHolder>
</body></html>
</asp:Content>
主(子节点:页眉)模板:
<asp:content ContentPlaceHolderId="header" runat="server">TEST</asp:content>
主(子节点:页脚)模板:
<asp:content ContentPlaceHolderId="footer" runat="server">TEST</asp:content>
我有 3 种文档类型(主、页眉、页脚),其 id 为页眉和页脚。
I have a simple master template with HTML tags and I want to put a footer and header in it. For some reason it doesn't display both the header and footer at the same time. Am I using ContentPlaceHolderId wrong? Should they not be all templates?
MASTER template
<asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server">
<head>
</head>
<body>
<asp:ContentPlaceHolder Id="header" runat="server"></asp:ContentPlaceHolder>
<asp:ContentPlaceHolder Id="footer" runat="server"></asp:ContentPlaceHolder>
</body></html>
</asp:Content>
Master (child node: header) template:
<asp:content ContentPlaceHolderId="header" runat="server">TEST</asp:content>
Master (child node: footer) template:
<asp:content ContentPlaceHolderId="footer" runat="server">TEST</asp:content>
I have 3 doc types (master, header, footer) with the id of header and footer.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
听起来您已将页眉/页脚模板设置为“网站主模板”模板的子级,这意味着您只能选择页眉或页脚模板中的一个。听起来您也已将它们设置为主页的子节点...我不确定您为什么要这样做。
您应该将页眉和页脚内容放入主模板中。如果您希望它是内容可编辑的(听起来您可能会这样做),请使用富文本字段“bodyHeader”和“bodyFooter”设置文档类型,然后使用
将内容插入到您的模板中。HTH,
本杰明
Sounds like you've set up your header/footer templates as children of your "site master" template, which means you can only pick either header or footer template. Also sounds like you've set them up as sub-nodes of your homepage... I'm not sure why you'd do this.
You should be putting header and footer content inside your main template. If you want it to be content-editable (which it sounds like you might), set up a document type with the rich text fields "bodyHeader" and "bodyFooter", then use
<umbraco:Item Field="bodyHeader" runat="server" />
to insert the content into your template.HTH,
Benjamin
做一件事。创建一个模板并在里面
< asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="服务器">
< div>标题< /div>
< div>正文< /div>
< div>页脚< /div>
< /asp:内容>
添加包含页眉、正文和页脚的 html 代码。
Do one thing. Create a template and inside
< asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server">
< div>header< /div>
< div>body< /div>
< div>footer< /div>
< /asp:Content>
add your html code which will contain the header,body and footer.