SharePoint Cross Site Content Query Web Part

3k views Asked by At

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

2

There are 2 answers

0
John Hansen On

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 }

1
Shane Jordan On

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.