Created
March 9, 2012 14:53
-
-
Save uniquelau/2006842 to your computer and use it in GitHub Desktop.
Column Calculations
This file contains 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
<?xml version="1.0" encoding="UTF-8"?> | |
<xsl:stylesheet | |
version="1.0" | |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
xmlns:umb="urn:umbraco.library" | |
exclude-result-prefixes="umb" | |
> | |
<xsl:output method="xml" omit-xml-declaration="yes"/> | |
<xsl:param name="currentPage"/> | |
<!-- get Columns - Laurie, 9th March 2012 --> | |
<xsl:template match="/"> | |
<xsl:apply-templates select="$currentPage/child::* [@isDoc]" /> | |
</xsl:template> | |
<xsl:template match="*"> | |
<div xsl:use-attribute-sets="better-magic"> | |
<section class="grid-easy"> | |
<xsl:value-of select="contentBody" disable-output-escaping="yes" /> | |
<xsl:if test="self::News"> | |
<h1><xsl:value-of select="contentHeader" /></h1> | |
<xsl:apply-templates select="child::NewsArticle" /> | |
</xsl:if> | |
</section> | |
</div> | |
</xsl:template> | |
<xsl:attribute-set name="better-magic"> | |
<xsl:attribute name="class"> | |
<xsl:variable name="column-count" select="count(parent::*/* [@isDoc])" /> | |
<xsl:choose> | |
<xsl:when test="$column-count = 1">grid_6 alpha omega</xsl:when> | |
<xsl:when test="$column-count = 2"> | |
<xsl:if test="position() = 1">grid_4 alpha</xsl:if> | |
<xsl:if test="position() = 2">grid_2 omega</xsl:if> | |
</xsl:when> | |
<xsl:when test="$column-count > 2"> | |
<xsl:text>grid_2 </xsl:text> | |
<xsl:choose> | |
<xsl:when test="position() mod 3 = 1">alpha</xsl:when> | |
<xsl:when test="position() mod 3 = 0">omega</xsl:when> | |
</xsl:choose> | |
</xsl:when> | |
</xsl:choose> | |
</xsl:attribute> | |
</xsl:attribute-set> | |
<xsl:template match="NewsArticle"> | |
<article> | |
<xsl:value-of select="contentTeaser" disable-output-escaping="yes" /> | |
</article> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It all works and has context. But I'm sure it could be more graceful.
I'll check exactly why it has context, but it certainly does. Lau (: