Copied to clipboard

Flag this post as spam?

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


  • Sam 63 posts 126 karma points
    Apr 08, 2011 @ 06:08
    Sam
    0

    Check if upload field has been fill in XSLT

    Hi all,

    I have created an upload field for the editor having the opportunity to download a pdf when clicked on a image button..

    What i want to do is in XSLT using new shema coding, check if upload field contains data and show the div sontaining the button, else hide div.

    I was wondering how to code this..

     

    My Code

    <div class="prdBox1">
             <div class="prdImg"><img src="{productPhoto}" width="180" height="140" alt="{@nodeName}" /></div>
             <div class="prdName"><xsl:value-of select="productName"/></div>
        </div>
        <div class="prdBox2">
             <div class="prdDesc"><xsl:value-of select="productDescription" disable-output-escaping="yes"/></div>
             <div class="prdButtons">

                 I WANT TO INSERT AND IF OR CHOOSE STATEMENT HERE..
                <div class="prdButtDownload"><href="{productDocument}" target="_blank"><img src="images/butt_download_details.png" width="117" height="21" alt="Download Details" /></a></div>
                


             </div>
        </div>

     

     

    THKS

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Apr 08, 2011 @ 08:20
    Jan Skovgaard
    0

    Hi Sam

    In order to fetch the data from the upload field you can create a XSLT macro that looks like this

    <xsl:if test="$currentPage/productDocument !=''">
    <div class="prdButtDownload"><a href="{productDocument}" target="_blank"><img src="images/butt_download_details.png" width="117" height="21" alt="Download Details" /></a></div>
    </xsl:if>

    Does this work for you?

    /Jan

  • Sam 63 posts 126 karma points
    Apr 08, 2011 @ 09:56
    Sam
    0

    Hi Jan,

    No it doesn't work for me...it just hiding all the div class="prdButtDownload" ..even those with uploaded data in the upload fields..i tried to redo the upload again after
    putting the code and republish entire site but in vain...

    Any other thoughts?

  • Pasang Tamang 258 posts 458 karma points
    Apr 08, 2011 @ 10:02
    Pasang Tamang
    0

    Hi Sam,

    As Jan's post, It will check if the currentpage's  productdocument has value or not. I'm using the same case to check value and works but there may be some situation like to check value in for each. So could you please post your some xslt, so we can fiqure out your problem?

    Thanks

    Pnima

  • Kim Andersen 1447 posts 2196 karma points MVP
    Apr 08, 2011 @ 10:39
    Kim Andersen
    1

    Hi Sam

    I guess you're inside some kind of loop in your code because you're not using $currentPage anywhere, so you might want to remove the $currentPage/ from Jan's code. I mean change the if to this:

    <xsl:if test="productDocument !=''">

    /Kim A

  • Sam 63 posts 126 karma points
    Apr 08, 2011 @ 11:37
    Sam
    0

    Hi you all,
         Kim you were right as want in a kind of loop...
    You're solution do the trick.
    Here's my complete code:
    <!-- The fun starts here -->
    <xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']">
     
    <xsl:sort order="descending" select="@createDate"/> 
       
    <div class="prdLt">
      
                  
       <xsl:if test="string(./productNew) = '1'">
         <xsl:element name="div">
           <xsl:attribute name="class">prdTagNew</xsl:attribute>
         </xsl:element>
        </xsl:if>
       
        <div class="prdBox1">
             <div class="prdImg"><img src="{productPhoto}" width="180" height="140" alt="{@nodeName}" /></div>
             <div class="prdName"><xsl:value-of select="productName"/></div>
        </div>
        <div class="prdBox2">
             <div class="prdDesc"><xsl:value-of select="productDescription" disable-output-escaping="yes"/></div>
             <div class="prdButtons">
               
                <xsl:if test="productDocument !=''">
                <xsl:element name="div">
                   <xsl:attribute name="class">prdButtDownload</xsl:attribute>
                      <a>
                        <xsl:attribute name="href"><xsl:value-of select="productDocument"/></xsl:attribute>
                        <xsl:attribute name="target">blank</xsl:attribute>
                        <img src="images/butt_download_details.png" width="117" height="21" alt="Download Details" />
                        
                      </a>
                </xsl:element>
               </xsl:if>
                <div class="prdButtAdd"><href="#"><img src="images/butt_add_basket.png" width="107" height="21" alt="Add to Basket" /></a></div>
             </div>
        </div>
      
      
    </div>
      
    </xsl:for-each>
    </xsl:template>
    THANKS YOU ALL FOR YOUR CONTRIBUTION.
    This forum is helping me a lot and learning much with you guys.

  • Kim Andersen 1447 posts 2196 karma points MVP
    Apr 08, 2011 @ 14:41
    Kim Andersen
    0

    Great to see that you got it solved Sam!

    Have a nice weekend...

    /Kim A

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Apr 08, 2011 @ 20:04
    Jan Skovgaard
    0

    Ah yeah, should have thought of that scenario...I just provided the method to do the check :-)

    /Jan

Please Sign in or register to post replies

Write your reply to:

Draft