Extending Content Query Web Part: Code Now Available

I presented my Extending Content Query Web Part session at TechEd 2009, introducing solution to aggregate data in SharePoint. Code available.

At TechEd 2009 in LA a few weeks back, Todd Baginski and I co-presented a session OFC405 - Extending the Content Query Web Part to Aggregate Data Across Site Collections and External Sources where we introduced a solution that addresses a common challenge in today’s SharePoint sites: aggregating content ACROSS site collections. It took some time, but we finally got the code cleaned up and posted for you to download and kick the tires too.

Now some will see this as a replacement to the Content Query Web Part (CQWP)but it isn’t. That is still the ideal way to aggregate content within an existing site collection as it contains a robust caching and is tweaked for peak performance of highly trafficked sites.

What we set out to do was to work on a solution that would do the following:

  • Aggregate content across site collections
  • Aggregate content from external sources

So after considerable planning; here’s what we came up with… a detailed UML diagram complete with loads of test cases:

Content Planning

Content Planning

OK… joking aside, here’s what we did as our architecture is actually quite simple:

  • Create a provider-like implementation where…
  • The Content Monster Web Part (CMWP) acts as a provider selector (sort of like how the SmartPart works selecting a user control) for installed providers
  • The CMWP calls the selected provider, passing in properties. The provider does it’s work and hands back results in XML format.
  • the CMWP takes the XML formatted results and runs them through the specified XSLT file to generate the HTML markup used in rendering.

It is really that simple! The current code is a working proof of concept… Todd and I have a lot of work to do to take it where we want it to go. But so far you’ll find the working Web Part, a sample provider and two real world providers that rollup content from Azure and using the SharePoint search API (for cross-site collection aggregation). You’ll see more coming as we get through the summer and into the fall.

You can download the current working code from the MSDN Code Gallery project we set up. Note there are a few releases so make sure you get what you’re looking for!

Andrew Connell
Developer & Chief Course Artisan, Voitanos LLC. | Microsoft MVP
Written by Andrew Connell

Andrew Connell is a web & cloud developer with a focus on Microsoft Azure & Microsoft 365. He’s received Microsoft’s MVP award every year since 2005 and has helped thousands of developers through the various courses he’s authored & taught. Andrew’s the founder of Voitanos and is dedicated to helping you be the best Microsoft 365 web & cloud developer. He lives with his wife & two kids in Florida.

Share & Comment