Site Path

Ray's Avatar

Ray

02 Jun, 2015 06:49 PM

Hi

I am getting different URL paths and was wondering why it works in one case, but not another.

For instance, when I use

<xsl:attribute name="href"><xsl:value-of select="section-image/path"/></xsl:attribute>

When viewing the HTML source, it returns ../../../assets/images/mypic.jpg and clicking on the a href tag shows the image.

When I put it into a variable
<xsl:variable name="imagepath" select="section-image/path"/>
and have this markup:
<xsl:attribute name="style">background-image: url('<xsl:value-of select="$imagepath"/>')</xsl:attribute>

The result is /assets/images/mypic.jpg

The image doesn't show.

Any help would be appreciated or please let me know what I am doing wrong.
Thanks

  1. 1 Posted by Bradley Wagner on 02 Jun, 2015 07:11 PM

    Bradley Wagner's Avatar

    Hi Ray, href is what we consider a "recognized" link-containing attribute so it is automatically re-written on render. In fact, both of those values resolve to /assets/images/mypic.jpg; it's just that the page renderer is smart enough to recognize the one inside of an href as a link to another asset.

    For the second one, you'll need to wrap your URL in Cascade's [system-asset] pseudo-tags.

    This would look like:

    <xsl:attribute name="style">background-image: url('[system-asset]<xsl:value-of select="$imagepath"/>[/system-asset]')</xsl:attribute>
    

    Give that a try and let us know if that does the trick.

    Also be sure to read through the linking documentation for a comprehensive list of how to link to assets in various contexts.

    Please let me know if you have any questions.

    Thanks!

  2. 2 Posted by Ray on 03 Jun, 2015 03:23 PM

    Ray's Avatar

    Thanks alot for the quick response. It worked.
    Cheers

  3. 3 Posted by Bradley Wagner on 03 Jun, 2015 03:29 PM

    Bradley Wagner's Avatar

    Great, Ray! Glad to hear it. I'm going to go ahead and close this discussion for now.

  4. Bradley Wagner closed this discussion on 03 Jun, 2015 03:29 PM.

Discussions are closed to public comments.
If you need help with Cascade CMS please start a new discussion.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

 

26 Aug, 2016 01:19 PM
25 Aug, 2016 03:02 PM
25 Aug, 2016 12:50 PM
24 Aug, 2016 08:43 PM
24 Aug, 2016 07:20 PM
21 Aug, 2016 01:20 PM