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 created 3 properties in a document.
1. MediaPicker2. Left (numeric)3. Right (numeric)
The user selected an image for the page then has two numeric fields to put in a top and left value which I will set as css properties on the image.
Two questions:
1. Is there anyway I can stop the user typing in text? If they do, and save the document then the field ends up being black.
2. If they do type in a text value or leave it blank, my XSLT checks do not reflect the fact that nothing is in there,
An example of my XSLT is below: No matter what I do I cannot seem to get a check back on the empty property passed into the macro.
<?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:param name="currentPage"/> <xsl:param name="ImgTop" select="macro/ImgTop" /> <xsl:param name="ImgRight" select="macro/ImgRight" /> <xsl:param name="ImgSrc" select="macro/ImgSrc" /> <xsl:template match="/"> <!-- start writing XSLT --> <xsl:choose> <xsl:when test="$ImgTop='NaN' or $ImgTop='' or $ImgTop=Null"> Hey nothing came through. </xsl:when> </xsl:choose> </xsl:template> </xsl:stylesheet>
Hello!
I don't know about question 1, but about question 2, I usually do the following and it works quite well at figuring out that a variable is empty:
<xsl:when text="string-length($ImgTop)=0">
....
</xsl:when>
Hi Dimitri - thanks for this. I eventually went with a Razor solution as it gave me more control over the variable.
I've made a note of this though for the future.
Thanks for taking the time to help.
No problem! Good luck with your project. (I made a little typo by the way. Instead of "when test" I wrote "when text" :) )
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Checking for null parameters in macro
Hi,
I have created 3 properties in a document.
1. MediaPicker
2. Left (numeric)
3. Right (numeric)
The user selected an image for the page then has two numeric fields to put in a top and left value which I will set as css properties on the image.
Two questions:
1. Is there anyway I can stop the user typing in text? If they do, and save the document then the field ends up being black.
2. If they do type in a text value or leave it blank, my XSLT checks do not reflect the fact that nothing is in there,
An example of my XSLT is below: No matter what I do I cannot seem to get a check back on the empty property passed into the macro.
Hello!
I don't know about question 1, but about question 2, I usually do the following and it works quite well at figuring out that a variable is empty:
<xsl:when text="string-length($ImgTop)=0">
....
</xsl:when>
Hi Dimitri - thanks for this. I eventually went with a Razor solution as it gave me more control over the variable.
I've made a note of this though for the future.
Thanks for taking the time to help.
No problem! Good luck with your project. (I made a little typo by the way. Instead of "when test" I wrote "when text" :) )
is working on a reply...