Multiple Page Templates
Version |
Date |
Changes |
1.0 |
2008-07-1 6 |
Initial version. |
Description
Presently, the page template for ePublisher, Page.asp, is one size fits all. The reason it fits all is due to support for conditions in ePublisher page templates.
Customers on wwp-users requested that ePublisher support multiple page templates which are then associated with different page styles in the ePublisher UI.
Possible Approach
To start, you'll need to override the file that controls which page template is loaded:
<Format>/Transforms/pages.xsl
We load the default page template, though one can add an option for selecting a different one (or just use the page style name). It would involve something like:
Replace "GlobalPageTemplate" with "VarPageTemplate" where necessary.
- Load your custom page template using either the style name or an option:
<xsl:variable name="VarPageTemplatePath"> <xsl:variable name="VarPageTemplateOption" select="$ParamPageStyle/wwproject:Options/wwproject:Option[@Name = 'page-template']/@Value" /> <xsl:choose> <xsl:when test="$ParamPageStyle/@Name = 'Blue'"> <xsl:value-of select="wwuri:AsFilePath('wwformat:Pages/Blue.asp')" /> </xsl:when> <xsl:when test="$VarPageTemplateOption = 'Red'"> <xsl:value-of select="wwuri:AsFilePath('wwformat:Pages/Red.asp')" /> </xsl:when> <xsl:otherwise> <xsl:value-of select="$GlobalPageTemplatePath" /> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name="VarPageTemplate" select="wwexsldoc:LoadXMLWithoutResolver($VarPageTemplatePath)" />
Limitations
One would need to be careful about doing this in a project with multiple formats. What happens when one of the formats does not define the requested page template?
2010-07-14
Project was reviewed and quickly revealed that the above notes are incomplete. The final code looks like:
<xsl:template name="Page"> <xsl:param name="ParamFilesSplits" /> <xsl:param name="ParamSplits" /> <xsl:param name="ParamBehaviorsFile" /> <xsl:param name="ParamBehaviors" /> <xsl:param name="ParamLinks" /> <xsl:param name="ParamTOCData" /> <xsl:param name="ParamBreadcrumbTOCEntry" /> <xsl:param name="ParamFilesDocumentNode" /> <xsl:param name="ParamSplit" /> <xsl:param name="ParamDocument" /> <xsl:param name="ParamContent" /> <!-- Page Rule --> <!-- --> <xsl:variable name="VarPageRule" select="wwprojext:GetRule('Page', $ParamSplit/@stylename)" /> <!-- Page Template --> <!-- --> <xsl:variable name="VarPageTemplatePath"> <xsl:choose> <xsl:when test="$ParamSplit/@stylename = 'LastPage'"> <xsl:value-of select="wwuri:AsFilePath('wwformat:Pages/PageLast.asp')" /> </xsl:when> <xsl:otherwise> <xsl:value-of select="$GlobalPageTemplatePath" /> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name="VarPageTemplate" select="wwexsldoc:LoadXMLWithoutResolver($VarPageTemplatePath)" />
with additional references to GlobalPageTemplate and GlobalPageTemplatePath replaced with VarPageTemplate and VarPageTemplatePath respectively.
Updated project attached:
wwp_wiki_sample.2010-07-14.zip
NOTE: Original project was configured to use 2009.3 transforms, but was actually running 2008.1 transforms. Project was updated by removing all unnecessary/unmodified transforms from the Formats folder and then picking up changes made in the 2009.3 release.