Created
September 18, 2013 20:07
-
-
Save ijy/6614868 to your computer and use it in GitHub Desktop.
Generate a random background image with XSLT, CSS, and Symphony CMS.
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
<!-- Add the 'math' namespace to your XML stylesheet (so we can use 'math:random') --> | |
<xsl:stylesheet version="1.0" | |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
xmlns:math="http://exslt.org/math" | |
extension-element-prefixes="math"> | |
<!-- Pick a random number between 1 - 10 and set as a variable --> | |
<xsl:variable name="random-bg"> | |
<xsl:value-of select="(floor(math:random()*10) mod 10) + 1" /> | |
</xsl:variable> | |
<!-- Call the variable as an 'attribute value template' --> | |
<body class="bg-image-{$random-bg}"> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment