Search code examples
xsltumbraco

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:

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.

alt text
(source: 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

alt text
(source: 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.

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?

Thanks for your help!


Solution

  • I figured this out.

    Here is the 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.

    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>​