Created
April 23, 2011 20:52
-
-
Save greystate/938971 to your computer and use it in GitHub Desktop.
Code listings for "xsl:include or xsl:import?" (Pimp My XSLT article)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <xsl:stylesheet ... > | |
| <!-- All media goes through here --> | |
| <xsl:template match="*" mode="media"> | |
| <xsl:variable name="mediaNode" select="umbraco.library:GetMedia(., false())" /> | |
| <xsl:apply-templates select="$mediaNode[not(error)]" mode="media" /> | |
| </xsl:template> | |
| <!-- Image file --> | |
| <xsl:template match="Image" mode="media"> | |
| <img src="{umbracoFile}" width="{umbracoWidth}" height="{umbracoHeight}" alt="[image]" /> | |
| </xsl:template> | |
| <!-- Flash file --> | |
| <xsl:template match="File[umbracoExtension = 'swf']" mode="media"> | |
| <!-- Go nuts with <object> and <embed> etc. --> | |
| </xsl:template> | |
| </xsl:stylesheet> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <xsl:stylesheet ... > | |
| <xsl:param name="currentPage" /> | |
| <xsl:template match="/"> | |
| <!-- If an image was picked, render it --> | |
| <xsl:apply-templates select="$currentPage/pageImage[normalize-space()]" /> | |
| </xsl:template> | |
| <xsl:template match="pageImage"> | |
| <xsl:apply-templates select="." mode="media" /> | |
| </xsl:template> | |
| <!-- Include standard templates for Media output --> | |
| <xsl:include href="MediaHelper.xslt" /> | |
| </xsl:stylesheet> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- PDF file, render link --> | |
| <xsl:template match="File[umbracoExtension = 'pdf']" mode="media"> | |
| <a href="{umbracoFile}" type="application/pdf"> | |
| <xsl:text>Download PDF</xsl:text> | |
| <xsl:value-of select="concat(' (~', ceiling(umbracoBytes div 1024), 'KB)')" /> | |
| </a> | |
| </xsl:template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <xsl:stylesheet ... > | |
| <xsl:param name="currentPage" /> | |
| <xsl:template match="/"> | |
| <!-- If an image was picked, render it --> | |
| <xsl:apply-templates select="$currentPage/pageImage[normalize-space()]" /> | |
| </xsl:template> | |
| <xsl:template match="pageImage"> | |
| <xsl:apply-templates select="." mode="media" /> | |
| </xsl:template> | |
| <!-- Include standard templates for Media output --> | |
| <xsl:include href="MediaHelper.xslt" /> | |
| <!-- Overwrite default <img> output to use the version attribute for cache-busting --> | |
| <xsl:template match="Image" mode="media"> | |
| <img src="{umbracoFile}?v={@version}" width="{umbracoWidth}" height="{umbracoHeight}" alt="[image]" /> | |
| </xsl:template> | |
| </xsl:stylesheet> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- Image (1057) : 108 Minutes --> | |
| <img src="/media/4815/162342x.png" width="16" height="9" alt="[image]" /> | |
| <!-- Saved by Reyes @ 2010-10-30T15:16:23 --> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <xsl:stylesheet ... > | |
| <!-- Import standard templates for Media output --> | |
| <xsl:import href="MediaHelper.xslt" /> | |
| <!-- Extend output for <Image> and <File> objects --> | |
| <xsl:template match="Image | File" mode="media"> | |
| <xsl:comment> | |
| <xsl:value-of select="concat(name(), '(', @id, ') : ', @nodeName)" /> | |
| </xsl:comment> | |
| <!-- Do the magic .super() thing... --> | |
| <xsl:apply-imports /> | |
| <xsl:comment> | |
| <xsl:value-of select="concat('Saved by ', @writerName, ' @ ', @updateDate)" /> | |
| </xsl:comment> | |
| </xsl:template> | |
| </xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment