views:

815

answers:

4

Besides buying a third party, what is the best approach to extending the CQWP control to include content from a seperate site collection?

A: 

You can not override the content query webpart to query another site collection. It uses the SPSiteDataQuery http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsitedataquery.aspx , this is limited to the current site collection. But you could create a custom webpart that has similar function but looks to a site collection by url rather than from the SPContext. Example:

using (SPSite site = new SPSite("http://server/")) { // build a SPSiteDataQuery // include the CAML query // use the datatable of results to create XML // use XSLT to transform XML into HTML }

John Hansen
A: 

Actually, we figured it out. We were successfully able to inherit from CQWP and use a ton of reflector to reproduce a lot of the CQWP code and got it working quite well to query other site collections, as well as the current. The code involved was not for the faint of heart though.

Shane Jordan
A: 

Freaking awesome. I don't suppose you're willing to share?!

panoone
A: 

Can you provide the code to this newly created wp?

michael