In one of the sharepoint projects that i was working on , there was a content query web part which displayed articles from an Articles subsite. There was a filter on the queried data which only showed data as per a metadata term. Now this web part was present in every other subsite. So in some of the sites it showed data while in others since there was not data to be shown, an empty web part was rendered.
Now my client wanted to show a custom message to the user in the CQWP like :
"No Items are currently available. Please check again soon."
So in order to do this i made some changes to the "ContentQueryMain.xsl" file in :
"\Style Library\XSL Style Sheets\ContentQueryMain.xsl"
There is one template in this file which indicates an "Empty" data. It's called "OuterTemplate.Empty".
I replaced that template with my own code and it worked perfectly fine.So anytime if there was no data to be shown in the CQWP, a custom message was displayed.
The code which i used for the "OuterTemplate.Empty" template is as follows:
Now my client wanted to show a custom message to the user in the CQWP like :
"No Items are currently available. Please check again soon."
So in order to do this i made some changes to the "ContentQueryMain.xsl" file in :
"\Style Library\XSL Style Sheets\ContentQueryMain.xsl"
There is one template in this file which indicates an "Empty" data. It's called "OuterTemplate.Empty".
I replaced that template with my own code and it worked perfectly fine.So anytime if there was no data to be shown in the CQWP, a custom message was displayed.
The code which i used for the "OuterTemplate.Empty" template is as follows:
<xsl:template name="OuterTemplate.Empty">
<xsl:param name="EditMode" />
<div id="linkitem" class="item link-item">
No Items are currently available. Please check again soon.
</div>
<xsl:if test="$EditMode = 'True' and string-length($cbq_errortext) = 0">
<div class="wp-content description">
<xsl:value-of disable-output-escaping="yes" select="$cbq_viewemptytext" />
</div>
</xsl:if>
</xsl:template>


