Content Query ‘No results” message

By default Content Query Web Parts (CQWP) don’t display any text on a page when no results are returned. The message is only displayed in “edit mode” when a content manager or developer is editing the page. This can be frustrating because you might want to display a message that says that nothing has been returned. In my case we wanted to query a calendar for upcoming events that meet some conditions and a message if there wasn’t any. The solution is simple:

1. Open Designer and your root site collection (http:// [site collection name])

2. Select All Files > Style Library > XSL Style Sheets

3. Open ContentQueryMain.xsl  (good idea to make a copy called custom)

4. Look for the item template OuterTemplate.Empty:

contentQuerymain

Note the xsl:if tag that indicates that the message will only be shown when in edit mode. Add a custom message above.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s