简体   繁体   English

Umbraco,XSLT,如何在父页面中呈现子内容?

[英]Umbraco, XSLT, How do I render child content in a parent page?

I have content that I've structured as follows in the content section in umbraco: 我的内容我在umbraco的内容部分中的结构如下:

Items under the content node that have a folder icon are Content Pages. 内容节点下具有文件夹图标的项目是内容页面。 A content page can have another content page as a child or a content section which are the items with doc with image icon. 内容页面可以具有作为子项的另一内容页面或具有带有图像图标的doc的项目的内容部分。

替代文字
(source: flickr.com ) (来源: flickr.com

I have a settings section that I've structured as follows: 我有一个设置部分,我的结构如下:

Each SectionDocumentType has a limited number of available templates the user can select 每个SectionDocumentType都有用户可以选择的有限数量的可用模板

替代文字
(source: flickr.com ) (来源: flickr.com

What I'd like to do is to render Sections as rows of data in a content page while ignoring child content pages. 我想要做的是在内容页面中将Sections呈现为数据行,同时忽略子内容页面。

I'd like each section "row" to display template and all. 我希望每个部分“行”显示模板和所有。

I'm new to XSLT so I'm wondering how could I do this? 我是XSLT的新手,所以我想知道我怎么能这样做?

Thanks for your help! 谢谢你的帮助!

I figured this out. 我想通了。

Here is the xslt: 这是xslt:

<?xml version="1.0" encoding="UTF-8"?>
   <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
       <xsl:stylesheet version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
       xmlns:msxml="urn:schemas-microsoft-com:xslt"
     xmlns:umbraco.library="urn:umbraco.library"
     xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon"
     xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes"
     xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath"
     xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions"
     xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings"
     xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets">
   <xsl:output method="html" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<xsl:template match="/">
  <xsl:for-each select="$currentPage/child::*[@isDoc][@nodeType != 1230]">
      <xsl:value-of select="umbraco.library:RenderTemplate(@id,@template)" disable-output-escaping="yes"/>
  </xsl:for-each>
</xsl:template>

</xsl:stylesheet>

Also I had to add this line to my content section <umbraco:DisableRequestValidation runat="server"/> in my content section templates. 另外,我必须在我的内容部分模板中将此行添加到我的内容部分<umbraco:DisableRequestValidation runat="server"/>

Here is how you use it in your page template. 以下是在页面模板中使用它的方法。

<asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server">
**<umbraco:DisableRequestValidation runat="server"/>** 
**YOUR HTML GOES HERE**
</asp:Content>​

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM