CQWP: 30 Tips #2

Following from Tip #1, when you create your custom .dwp.  Do as little configuration as possible to the out of the box (OOTB) CQWP before exporting it.  I usually just add the OOTB CQWP to a page, then go into its appearance tab to update its web part title to  Contoso Content Query or PM Content Query before exporting it.  This way, when you add it back into the site collection’s web part gallery it’s as close to the original as possible.

Share:
  • Print
  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Yahoo! Buzz
  • Twitter
  • Google Bookmarks
  • LinkedIn
  • Reddit
  • RSS

CQWP: 30 Tips #1

I’m speaking March 8 at the 2012 Heartland Region SharePoint Conference (http://iccsharepoint.com).  My presentation, titled “CQWP, The Most Powerful Tool You’re Underutilizing.” will be a deep dive into the CQWP covering how to use it and how to customize it.  I hope to show why I think CQWP is one of the most powerful tools available to a SharePoint dev. 

In honor of the upcoming presentation, I’m going to post 30 CQWP tips.  I had this idea a little while ago, but do to the power of procrastination, I now have exactly 30 days until the conference. 

If you haven’t registered yet, you can still do so at http://iccsharepoint.com, but seats are filling up fast.

On to the post: 3 xsl files go into creating the CQWP’s layouts.  ItemStyle.xsl controls the available item layouts, Header.xsl controls the available group layouts, and ContentQueryMain.xsl acts as the broker that lays down the foundation and calls out to the header and item styles as needed.  To customize a CQWP layout, you’ll need to create copies of one or more of these .xsl files and then update a CQWP’s .dwp (.webpart) to reference your copies.

Here’s my typical working scenario.  As early as possible, if I identify the need for a CQWP in a site collection, I’ll create copies of the .xsl files.  I’ll create the copies side by side with the originals but name them according to the client (Contoso_ItemStyle.xsl, Contoso_Header.xsl, Contoso_ContentQueryMain.xsl).  If I have something more specialized, such as a set of styles in mind for use in a project management collection, I may name them something like PM_ItemStyle.xsl, PM_Header.xsl, PM_ContentQueryMain.xsl.  Then I’ll create a new .dwp (.webpart) that references the new .xsl files and upload it to the webpart gallery, named something like Contoso CQWP (or PM CQWP).

Tip #1:  Although you’re immediate customization need may only require updates to one of the 3 .xsl files. I recommend you ALWAYS copy all 3 and make reference to them in the .dwp. By doing so, you can make changes in the other two as needed later on without having to create a new .dwp. Thus your future changes will be available to your existing CQWPs (as long as you based them on your updated .dwp).

Share:
  • Print
  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Yahoo! Buzz
  • Twitter
  • Google Bookmarks
  • LinkedIn
  • Reddit
  • RSS