Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Saqib Razzaq 5 posts 27 karma points
    Aug 05, 2009 @ 02:10
    Saqib Razzaq
    0

    Embed child pages in parent page

    Hi all,

    I am tasked with creating a tool through which users will be able to create multiple coupons. A coupon will typically include images and text which the user should be able to enter.

    We will have 4 or 5 different types of coupon templates and corresponding document types.

    I was thinking of creating a coupons folder under which users can create the coupons with appropriate data.

    The part that I am struggling with is that when a user navigates to http://site.com/coupons.aspx, I want all the coupons that have been created to show up on this page one after the other.

    I am able to access individual data items through xslt, but I would like to retrieve the fully rendered coupon page to embed in this page. Basically, I want the template code to be applied and then inserted into this page.

    Is this even possible? Let me know.

    Thanks

    -zak

  • Lee 1130 posts 3088 karma points
    Aug 05, 2009 @ 07:22
    Lee
    1

    You could easily adapt Warrens XSLT file SubNavi.xsl in the CWS2 Package - This gets all the child pages of a node, so if they hit coupons.aspx anything created under the coupons page would be selected

        <xsl:variable name="rootTextpageNode" select="$currentPage/ancestor-or-self::node [@level = 2 and @nodeTypeAlias = 'CWS_Textpage']" />
        <div class="secondaryNav">      
            <ul>
                <xsl:for-each select="$rootTextpageNode/node">
                    <li>
                        <xsl:if test="$currentPage/ancestor-or-self::node/@id = current()/@id">
                            <xsl:attribute name="class">
                                <xsl:text>selected</xsl:text>
                            </xsl:attribute>
                        </xsl:if>
                      
                        <a href="{umbraco.library:NiceUrl(current()/@id)}">
                            <span>
                                <xsl:value-of select="current()/@nodeName"/>
                            </span>
                        </a>
                    </li>
                </xsl:for-each>     
            </ul>
        </div>

    Obviously you would need to add in your property names to pull out and display - If you have different templates then just use an 'if' @nodeTypeAlias = 'whatever' one bit of html and if @nodeTypeAlias 'another' then another bit of html etc..

  • Saqib Razzaq 5 posts 27 karma points
    Aug 06, 2009 @ 16:36
    Saqib Razzaq
    0

    Thanks for your reply Lee...

    I managed to figure it out. The solution was in "RenderTemplate" method in umbraco.library. I basically loop over all the child pages and call RenderTemplate providing it the child page id and child template id. Here is the snippet

    <xsl:output method="html"/>

    <xsl:param name="currentPage"/>

    <xsl:template match="/">
      <xsl:call-template name="drawNodes">
        <xsl:with-param name="parent" select="$currentPage/ancestor-or-self::node [@level=1]"/>
      </xsl:call-template>
    </xsl:template>

    <xsl:template name="drawNodes">
      <xsl:param name="parent"/>
      <xsl:for-each select="$parent/node">
        <xsl:call-template name="renderTemplate">
          <xsl:with-param name="pageId" select="@id" />
          <xsl:with-param name="templateId" select="@template" />
        </xsl:call-template>
        <hr/>
      </xsl:for-each>
    </xsl:template>

    <xsl:template name="renderTemplate">
     <xsl:param name="pageId"/>
     <xsl:param name="templateId"/>
     <xsl:value-of select="umbraco.library:RenderTemplate($pageId, $templateId)" disable-output-escaping="yes"/>
    </xsl:template>

Please Sign in or register to post replies

Write your reply to:

Draft