Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi
I have a problem whit an background images that dosen't come out right. Im trying to put a Style into a <a> in my Xslt file. but something goes wrong whit the path to the background images.
In the Macro I have set the Parameters like this:
I have an xslt file containing this:
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxml="urn:schemas-microsoft-com:xslt" xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets "><xsl:output method="xml" omit-xml-declaration="yes"/> <xsl:variable name="temp" select="string(/macro/urlNumber)"/> <xsl:variable name="class" select="string(/macro/className)"/> <xsl:variable name="text" select="string(/macro/tagText)"/> <xsl:variable name="bgImg" select="string(/macro/bgImage)"/><xsl:param name="currentPage"/><xsl:template match="/"> <xsl:choose> <xsl:when test="$class != '' and $text != '' and $temp != ''"> <a href="{umbraco.library:NiceUrl($temp)}" class="{$class}" style="background:url({$bgImg}) no-repeat;"> <xsl:value-of select="$text" disable-output-escaping="yes"/> </a> </xsl:when> <xsl:when test="$temp != ''"> <xsl:value-of select="umbraco.library:NiceUrl($temp)"/> </xsl:when> </xsl:choose></xsl:template></xsl:stylesheet>
and the output on the page is this:
<a style="background:url(/media/8/iconData2.png72372409png) no-repeat;" class="readmore" href="/tekst-side/underside.aspx">se her</a>
What am I doing wrong?
Hi Kate,
The "mediaCurrent" parameter gives you an XML chunk, so you need to specifically select the umbracoFile element inside it:
<xsl:variable name="temp" select="/macro/urlNumber"/> <xsl:variable name="class" select="/macro/className"/> <xsl:variable name="text" select="/macro/tagText"/> <xsl:variable name="bgImg" select="/macro/bgImage/*/umbracoFile"/>
(And you don't need the string() thing, though it doesn't hurt anyone :-)
/Chriztian
It works perfect :-)
Thank you very much
You're welcome - and might I add, a perfect example of how to ask a question :-)
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
insert a background image in a a-tag
Hi
I have a problem whit an background images that dosen't come out right. Im trying to put a Style into a <a> in my Xslt file. but something goes wrong whit the path to the background images.
In the Macro I have set the Parameters like this:
I have an xslt file containing this:
and the output on the page is this:
What am I doing wrong?
Hi Kate,
The "mediaCurrent" parameter gives you an XML chunk, so you need to specifically select the umbracoFile element inside it:
(And you don't need the string() thing, though it doesn't hurt anyone :-)
/Chriztian
It works perfect :-)
Thank you very much
You're welcome - and might I add, a perfect example of how to ask a question :-)
/Chriztian
is working on a reply...