File Structure / Hierarchy
This is an open discussion with 6 replies, filed under General.
Search
in these cases you could use these two variables in xslt. $root
when you want to refer to your website. eg http://mywebsite.com
or $workspace
when you want to go directly to your workspace eg http://mywebsite.com/workspace
.
ah ok. That makes sense. It's interesting that, that variable doesn't work within the javascript block. Prolly because it would assume it's a js variable???
Thanks!
what do you mean within the javascript block?
If you're using it within javascript (&xslt combined) you have to use it normally like any other xslt variable
<xsl:value-of select='$workspace'/>
If you use CData blocks; you'd have to close them and open them again. As it would be interpreted as text.
<script> $.backstretch([ <xsl:for-each select='slider-background/entry/images/filename'> "../workspace/<xsl:value-of select='.'/>", </xsl:for-each> ], { fade: 750, duration: 4000 }); </script>
For some reason if I use the $workspace variable in place of just workspace it does not work.
For some reason if I use the $workspace variable in place of just workspace it does not work.
The reason behind this is actually very simple: when you are using the {$variable}
syntax, you are using the fact that this is invalid xml: <tag attribute="<xsl:value-of select="$variable"/>"/>
. To work around this, the curly brackets are invented, so it becomes: <tag attribute="{$variable}"/>
. Now, this is only needed inside attributes, so that's the only place where this notation works.
If you wanted to output the workspace url in your javascript, this would work:
<script> $.backstretch([ <xsl:for-each select='slider-background/entry/images/filename'> "<xsl:value-of select='concat($workspace, "/", .)'/>", </xsl:for-each> ], { fade: 750, duration: 4000 }); </script>
wow, ok that makes sense. Man I was trying some shady stuff.. ha.
Thanks!!!
Create an account or sign in to comment.
happy Monday,
In my master.xsl I have a script that calls this:
Now the issue is that this code works great from the homepage but when in the subpages ie www.site/about the code will not work since the path is now wrong. For it to work I have to use:
Should I just use absolute url?