Copied to clipboard

Flag this post as spam?

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


  • Fuji Kusaka 2203 posts 4220 karma points
    Jul 19, 2011 @ 21:54
    Fuji Kusaka
    0

    Checking if a field is empty in XSLT

    Hi Guys,

    Am having some issues with an if statement while using a xslt from changeable source. Here am checking one of my field is empty and if not i will display the link so as the user can download it.

    But doesnt seem to work.

     <xsl:variable name="pdfFile" select="$currentPage/newsPDF" />
    <ul class="eventList">
    <xsl:for-each select="umbraco.library:GetXmlNodeById($source)/* [@isDoc and string(umbracoNaviHide) != '1']">
       <xsl:sort select="current()/eventDate" order="descending"/>
          <!-- <xsl:if test="position () &lt;= $itemsToDisplay">-->
           
            <li class="eventLink">              
              <h1><a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="newsTitle"/> </a></h1>
            </li>
            <li style="padding-left:15px; ">
              
              <xsl:value-of select="newsImg"/>  
              <xsl:value-of select="newsDescription"/>                   
             
              <xsl:if test="$pdfFile != ''">
                  <xsl:element name="a">
                  <xsl:attribute name="href">
                       <xsl:value-of select="newsPDF"/>               
                  </xsl:attribute>Download the file
                </xsl:element>
              </xsl:if>         
              
            </li>
                      
        
    </xsl:for-each>
    </ul>

     

    //fuji

  • Tom Fulton 2030 posts 4996 karma points c-trib
    Jul 19, 2011 @ 22:12
    Tom Fulton
    0

    Hey Fuji,

    I think the problem is you are defining your $pdfFile variable for the $currentPage, instead of each item in the loop.

    Try instead moving it inside your for-each, and removing $currentPage

    <xsl:for-each select="umbraco.library:GetXmlNodeById($source)/* [@isDoc and string(umbracoNaviHide) != '1']">
       <xsl:sort select="current()/eventDate" order="descending"/>
      
       <xsl:variable name="pdfFile" select="newsPDF" />

    -Tom

  • Fuji Kusaka 2203 posts 4220 karma points
    Jul 19, 2011 @ 22:20
    Fuji Kusaka
    0

    Hi Tom,

    Yup its working now....but earlier I try using @alias=newsPDF which works at and at some point when i added the attributes i all when wrong...

    Am getting so confused with the strcuture of this website and am already @ 150 pages!!! 

    But Thanks again

     

    //fuji


     

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies