Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • René 327 posts 852 karma points
    Feb 06, 2013 @ 23:09
    René
    0

    Ultimatepicker - when nothing is chosen

    Hi Forum

    Umbraco version: umbraco v 4.11.4

    What i try to do:

    From a media folder i show some pdf files

     

    These i load in a ultimate picker

    The chosen PDF is avalible in the site for download

    Now my problem

    If nothing is chosen from the ultimatepicker, the "blue download box" on the site, should not be there.

    But if i set the ultimatepicker to "not chosen" any of the pdf i cant get it to work

    I have made a empty pdf and when i choose this one, it wont show any thing (As it should work)

    I test to see if the chosen media is /media/25602/empty.pdfpdf17059 - if it is, nothing is displayed.

    Othervise the download file is shown

    Here is my xslt.

    <xsl:template match="/">
    
            <xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/productChoosePDF, 0)" />
    
            <xsl:choose>
                <xsl:when test="$media= '/media/25602/empty.pdfpdf17059'">
    
                </xsl:when>
                <xsl:otherwise>
                    <xsl:variable name="url" select="$media/umbracoFile" />
                    <div class="information closable">
                        <a target="_blank" href="{$url}"><img src="/images/pdf_icon.png" alt="" />  Download product sheet </a>  
                    </div>
                </xsl:otherwise>
            </xsl:choose>
    
        </xsl:template>

    Recap

    I want to: when nothing is chosen from the ultimatedropdown it should not show anything in the download box.

    I cant figure out how to see if nothing is chosen.

    any ideas.. ?

    Tanks for this great CMS and forum

    René

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Feb 06, 2013 @ 23:15
    Tom Fulton
    0

    Hi,

    I think rather than selecting an "Empty" PDF, you should just test for an empty value in your field, like so:

    <xsl:if test="normalize-space($currentPage/productChoosePDF) and number($currentPage/productChoosePDF) &gt; 0">
    ....
    </xsl:if> 

    Hope this helps,
    Tom 

  • René 327 posts 852 karma points
    Feb 06, 2013 @ 23:39
    René
    0

    HI

    Tanks for quick reply

    When i test for this i get an error

    Error parsing the XSLT:

    System.OverflowException: Value was either too large or too small for an Int32. at System.Convert.ToInt32(Double value) at System.Double.System.IConvertible.ToInt32(IFormatProvider provider) at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) at System.Xml.Xsl.Runtime.XmlQueryRuntime.ChangeTypeXsltArgument(XmlQueryType xmlType, Object value, Type destinationType) at System.Xml.Xsl.Runtime.XmlQueryContext.InvokeXsltLateBoundFunction(String name, String namespaceUri, IList`1[] args) at (XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) at Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) at Execute(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlSequenceWriter results) at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer) at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, XmlWriter results, XmlResolver documentResolver) at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, TextWriter results) at umbraco.macro.GetXsltTransformResult(XmlDocument macroXML, XslCompiledTransform xslt, Dictionary`2 parameters) at umbraco.presentation.umbraco.developer.Xslt.xsltVisualize.visualizeDo_Click(Object sender, EventArgs e)

     

    As far as i have found out the "not chosen" from the ultimatepicker is not empty, when nothing is chosen, i have tryed &gt; &lt; null and empty string ' '
    I cant figure out what the value is when nothing is chosen
    Maybee i wrong on this 

    Here is my xslt now.  

    <xsl:template match="/">     
            <xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/productChoosePDF, 0)" />
            <xsl:value-of select="$media"/>
            <xsl:if test="normalize-space($currentPage/productChoosePDF) and number($currentPage/productChoosePDF) &gt; 0">
            <xsl:variable name="url" select="$media/umbracoFile" />
            <div class="information closable">
                <a target="_blank" href="{$url}"><img src="/images/pdf_icon.png" alt="" />  Download product sheet </a>  
            </div>
            </xsl:if> 
        </xsl:template>
  • Tom Fulton 2030 posts 4998 karma points c-trib
    Feb 06, 2013 @ 23:42
    Tom Fulton
    100

    Try moving the first two lines inside of the if block.  Otherwise its trying to call GetMedia without verifying something is selected, which will result in that error:

     <xsl:template match="/">                
    <xsl:if test="normalize-space($currentPage/productChoosePDF) and number($currentPage/productChoosePDF) &gt; 0">
    <xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/productChoosePDF, 0)" />
                    <xsl:value-of select="$media"/>
                    <xsl:variable name="url" select="$media/umbracoFile" />
                    <div class="information closable">
                            <a target="_blank" href="{$url}"><img src="/images/pdf_icon.png" alt="" />  Download product sheet </a>  
                    </div>
    </xsl:if> 
    </xsl:template>
  • René 327 posts 852 karma points
    Feb 06, 2013 @ 23:49
    René
    0

    Hi Tom 

    Tanks a lot, it worked. 

    Here is the final xslt

       <xsl:template match="/">                
            <xsl:if test="normalize-space($currentPage/productChoosePDF) and number($currentPage/productChoosePDF) &gt; 0">
                <xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/productChoosePDF, 0)" /> 
    
                <xsl:variable name="url" select="$media/umbracoFile"/>
                <div class="information closable">
                    <a target="_blank" href="{$url}"><img src="/images/pdf_icon.png" alt=""/>  Download product sheet </a>  
                </div>
            </xsl:if> 
        </xsl:template>
Please Sign in or register to post replies

Write your reply to:

Draft