Copied to clipboard

Flag this post as spam?

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


  • Anil Reddy 17 posts 37 karma points
    Nov 27, 2011 @ 11:38
    Anil Reddy
    0

    Want to hide content where the field is empty

    Need a quick help.

    I have a text string called questionHeading, In my xslt I need to hide when this field is empty, I know we need to use the if statement, but not sure how to do it.

    <?xml version="1.0" encoding="UTF-8"?>

    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <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" xmlns:CWS.Twitter="urn:CWS.Twitter" xmlns:umbraco.contour="urn:umbraco.contour" xmlns:PS.XSLTsearch="urn:PS.XSLTsearch" 
      exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets CWS.Twitter umbraco.contour PS.XSLTsearch ">

    <xsl:output method="xml" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage"/>

    <xsl:template match="/">

    <!-- The fun starts here -->
    <div class="faqs">
    <xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']">

    <!-- I NEED TO HIDE THIS CONTENT WHEN UMBRACO FIELD IS EMPTY -->
    <h2><xsl:value-of select="questionHeading"/></h2>
    </xsl:if>

    <!-- TILL HERE -->


    <h3><xsl:value-of select="question" disable-output-escaping="yes"/></h3>
    <div><p><xsl:value-of select="answer" disable-output-escaping="yes"/></p></div>
    </xsl:for-each>
    </div>

    </xsl:template>

    </xsl:stylesheet>

  • Rich Green 2246 posts 4006 karma points
    Nov 27, 2011 @ 11:43
    Rich Green
    0

    Hi,

    Try this

    <xsl:if test="questionHeading !=''">
    <h2><xsl:value-of select="questionHeading"/></h2>

    </xsl:if>

    Rich

  • Anil Reddy 17 posts 37 karma points
    Nov 27, 2011 @ 13:50
    Anil Reddy
    0

    Thanks Rich!!!

    You are my saviour :)

  • 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