TwitterLinkedInBlog

Saturday, March 28, 2009

SP2007 - How to hide a CQWP Group Header if it is Blank

By default, the CQWP Group Header displays (Blank) if the group by field is null. The desired behavior is to display nothing.

For example, add the following xsl template, SmallTextHiddenBlank, under the existing xsl template, SmallText, in the Header.xsl file in the Style Library. Then, choose the SmallTextHiddenBlank Header template in the CQWP Tool Part.

<xsl:template name="SmallTextHiddenBlank" match="*[@GroupStyle='SmallTextHiddenBlank']" mode="header">
  <xsl:choose>
    <xsl:when test="string-length(normalize-space(@*[name()=$Group])) = 0">
    </xsl:when>
    <xsl:otherwise>
      <div class="groupheader item small">
      <xsl:call-template name="OuterTemplate.GetGroupName">
        <xsl:with-param name="GroupName" select="@*[name()=$Group]"/>
        <xsl:with-param name="GroupType" select="$GroupType"/>
      </xsl:call-template>
      </div>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

1 comment:

Anonymous said...

I really appreciate this post, as I was trying a similar approach, but getting an appropriate test string was throwing me.

Thanks so much! MT