0 users online. Create an account or sign in to join them.Users

Search

happy Monday,

In my master.xsl I have a script that calls this:

 <xsl:for-each select='slider-background/entry/images/filename'>
       **"/workspace/<xsl:value-of select='.'/>",**
            </xsl:for-each>

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:

<xsl:for-each select='slider-background/entry/images/filename'>
           **"../workspace/<xsl:value-of select='.'/>",**
                </xsl:for-each>

Should I just use absolute url?

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.

&lt;script>
         $.backstretch([
        <xsl:for-each select='slider-background/entry/images/filename'>
       "../workspace/<xsl:value-of select='.'/>",
            </xsl:for-each>

      ], {
          fade: 750,
          duration: 4000
      });
  &lt;/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:

&lt;script>
     $.backstretch([
    <xsl:for-each select='slider-background/entry/images/filename'>
    "<xsl:value-of select='concat($workspace, "/", .)'/>",
        </xsl:for-each>

  ], {
      fade: 750,
      duration: 4000
  });
&lt;/script>

wow, ok that makes sense. Man I was trying some shady stuff.. ha.

Thanks!!!

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3 or above
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.0 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details