You could get your macro to write out an embedded style sheet segment e.g.
<style type="text/css"> body { background-image: url(img/whatever.png); } </style>
Then just place the macro in your <head></head> section in the template.
Or you could indeed just include the macro inside the <body> tag directly, writing out just the name of the image. Down to personal preference really, but the former option is more flexible.
thanx that worked put the code like this and placed the macro inside the header
should have thought of that :P
<xsl:param name="currentPage"/> <!-- write the media folders id number here to point to the correct folder --> <xsl:variable name="bannerFolder" select="1338"/>
Place a macro inside a style=""
hello i need to place a macro inside the <body style=" background-image:--here--; ">
or is there another way to set a style for the body tag within the macro itself? and then just have the macro on the page?
this is to be used with a random picture macro so the background image changes when ever the page is loaded.
Can't you generate the entire opening body tag with the macro?
Alternatively just make your macro generate inline css that assigns the background image to the body tag or a div if your choice.
You could get your macro to write out an embedded style sheet segment e.g.
Then just place the macro in your <head></head> section in the template.
Or you could indeed just include the macro inside the <body> tag directly, writing out just the name of the image. Down to personal preference really, but the former option is more flexible.
Just a tip... if you put your macro inside a quoted attribute, make sure your macro parameters use single quotes. e.g.
thanx that worked put the code like this and placed the macro inside the header
should have thought of that :P
<xsl:param name="currentPage"/>
<!-- write the media folders id number here to point to the correct folder -->
<xsl:variable name="bannerFolder" select="1338"/>
<xsl:template match="/">
<xsl:variable name="numNodes" select="count(umbraco.library:GetMedia($bannerFolder, 1)/node)"/>
<xsl:variable name="random" select="floor(Exslt.ExsltMath:random() * $numNodes) + 1"/>
<style type="text/css">
body {
background-image: url(<xsl:value-of select="umbraco.library:GetMedia($bannerFolder, 1)/node [position() = $random]/data"/>);
}
</style>
</xsl:template>
is working on a reply...