C1 v4: How do I turn off caching when embedding a function in a page template feature?

Topics: Troubleshooting, XSLT
Jun 13, 2013 at 8:19 PM
Edited Jun 13, 2013 at 11:01 PM
I'm trying to create a modified version of Composite.Navigation.Quickmap that will highlight the selected area by applying a class attribute to the current <li> tag.

My Template is:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:in="http://www.composite.net/ns/transformation/input/1.0" xmlns:lang="http://www.composite.net/ns/localization/1.0" xmlns:f="http://www.composite.net/ns/function/1.0" xmlns="http://www.w3.org/1999/xhtml" exclude-result-prefixes="xsl in lang f">
    <xsl:param name="toplinks" select="/in:inputs/in:result[@name='GetTopLinkXml']/TopLink" />
    <xsl:param name="sublinks" select="/in:inputs/in:result[@name='GetSubLinkXml']/SubLink" />
    <xsl:param name="pageId" select="/in:inputs/in:result[@name='GetPageId']" />
    <xsl:template match="/">
        <html>
            <head></head>
            <body>
                <xsl:if test="$toplinks">
                    <ul class="navigation">
                        <li><xsl:value-of select="$pageId"/></li>
                        <xsl:for-each select="$toplinks">
                            <li>
                                <xsl:if test="$pageId=@Page">
                                    <xsl:attribute name="class">selected</xsl:attribute>
                                </xsl:if>
                                <xsl:apply-templates select="." />
                                <xsl:if test="$sublinks[@TopLink.Id=current()/@Id]">
                                    <ul class="hidden">
                                        <xsl:for-each select="$sublinks[@TopLink.Id=current()/@Id]">
                                            <li>
                                                <xsl:if test="$pageId=@Page">
                                                    <xsl:attribute name="class">selected</xsl:attribute>
                                                </xsl:if>
                                                <xsl:apply-templates select="." />
                                            </li>
                                        </xsl:for-each>
                                    </ul>
                                </xsl:if>
                            </li>
                        </xsl:for-each>
                    </ul>
                </xsl:if>
            </body>
        </html>
    </xsl:template>
    <xsl:template match="TopLink | SubLink">
        <a href="~/Renderers/Page.aspx?pageId={@Page}">
            <xsl:choose>
                <xsl:when test="@Page.MenuTitle!=''">
                    <xsl:value-of select="@Page.MenuTitle" />
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="@Page.Title" />
                </xsl:otherwise>
            </xsl:choose>
        </a>
    </xsl:template>
</xsl:stylesheet>
The Function Calls are:
<functions>
    <f:function xmlns:f="http://www.composite.net/ns/function/1.0" name="Composite.Navigation.Quickmap.SubLink.GetSubLinkXml" localname="GetSubLinkXml">
        <f:param name="OrderByField" value="Position" />
        <f:param name="PropertyNames">
            <f:paramelement value="Page.Title" />
            <f:paramelement value="TopLink.Id" />
            <f:paramelement value="Position" />
            <f:paramelement value="Id" />
            <f:paramelement value="Page" />
            <f:paramelement value="Page.MenuTitle" />
        </f:param>
    </f:function>
    <f:function xmlns:f="http://www.composite.net/ns/function/1.0" name="Composite.Pages.GetPageId" localname="GetPageId" />
    <f:function xmlns:f="http://www.composite.net/ns/function/1.0" name="Composite.Navigation.Quickmap.TopLink.GetTopLinkXml" localname="GetTopLinkXml">
        <f:param name="PropertyNames">
            <f:paramelement value="Page.Title" />
            <f:paramelement value="Position" />
            <f:paramelement value="Id" />
            <f:paramelement value="Page" />
            <f:paramelement value="Page.MenuTitle" />
        </f:param>
        <f:param name="OrderByField" value="Position" />
    </f:function>
</functions>
Unfortunately, the GetPageId value isn't updating in a page template feature when I move from one page to another. This function works when embedded in a page content area, and a page template, but not in the page template feature. How do I make this update immediately upon page load?
Developer
Jun 14, 2013 at 6:43 PM
Make use of the SetServerPageCacheDuration function, setting its parameter to 0 - insert the following markup in your XSLT function, for example right below <body>:
<f:function name="Composite.Web.Response.SetServerPageCacheDuration" xmlns:f="http://www.composite.net/ns/function/1.0">
  <f:param name="MaxSeconds" value="0" />
</f:function>
Developer
Jun 19, 2013 at 7:10 AM
Looks like this is the same as here https://compositec1.codeplex.com/discussions/447343
Jul 2, 2013 at 2:54 PM
Thanks for your help, wysocki.

However, due to the dynamic changes I need to make in my new site, dependant upon the level the visitor is viewing, I went with creating separate functions for the metadata, headers and footers... à la the v3.2 methodology.... embedding them directly into the page templates.

It seems that the page template feature system is better suited for use in a more static type of site.