Using Utilities
This is an open discussion with 7 replies, filed under General.
Search
<xsl:call-template name="slider-images-for-background" />
I'm not quite sure what you're trying to do here, but I'd rather put he image list in a data-attribute or a variable and parse it on the client. ...
<xsl:variable name="quote"><xsl:text>"</xsl:text></xsl:variable> <xsl:variable name="imagelist"> [ <xsl:apply-templates select="slider-images-for-background/entry/images" mode="imagelist"/> ] </xsl:variable> <![CDATA[<script>window.imageslist = ]]><xsl:value-of select="$imagelist"/><![CDATA;</script>]]> ... <xsl:template match="entry/images" mode="imagelist"> <xsl:value-of select="concat($quote, $root, 'workspace/images/', .,$quote)"/> <xsl:if test="position() != last()">,</xsl:if> </xsl:template>
And in your client script just call your backstretch setup:
$.backstretch(window.imagelist)…
little update: This example should give you an idea
touchstone - so we are calling that template in the master.xsl since all the pages will call master.xsl? I had it as a utility that was called by each page?
I tried to add
<xsl:call-template name="slider-images-for-background" />
To the master page but got an error that the template was not found???
iwg - I just need to be able to single source the code.
got it, THANK!!!! Just called the template wrong.
hmmm that's not working. Is there a nesting issue?
In the master.xsl
I import background images utility then I call
<xsl:call-template name="slider-images-for-background" />
It applies the template but does not seem to evaluate this:
<xsl:for-each select='slider-images-for-background/entry/images/filename'> "http://www.mayerseedline.com/symphony/workspace/images/<xsl:value-of select='.'/>", </xsl:for-each>
However it (the call template) works perfectly if I call the template within any of the page.xsl.
within the script.
looks like an xpath issue so I did
<xsl:for-each select='**//**slider-images-for-background/entry/images/filename'>
instead of
<xsl:for-each select='slider-images-for-background/entry/images/filename'>
Prob wrong but it works.. :)
Create an account or sign in to comment.
Hey Folks,
I have the following working code
I need to use it on all pages so I turned it into a utilities and imported it: But I don't know how to make it work :( I've imported it the utility looks like: