locked
Configure CQWP to read data from different sites RRS feed

  • Question

  • i have a requirement where i need my Content by Query web part to read data from different sites(one site at a time).

    now i have different subsites: rootsite, subsite 1and subsite 2

    my CQWP is hosted on a page test.aspx of subsite 2.

     now if a user is coming from subsite 2 to test.aspx i want CQWP to read data from subsite 2 only, if he is coming from subsite1 then data source should be subsite 1 anf if from rootsite then it should read only from root site.

    i can provide site name in query string but how do i change the data source of CQWP??

     

    Also there might be a scenario where a site is hosted on different server.

     

    • Moved by Mike Walsh FIN Thursday, August 18, 2011 8:11 AM Not general (From:SharePoint - General Question and Answers and Discussion (pre-SharePoint 2010))
    Thursday, August 18, 2011 6:26 AM

Answers

  • Hi,

    If you want to do the cross web application or cross site collection queries then you cannot do this with out of the box CQWP.

    either you can try this blog post to achieve this , http://passionatetechie.blogspot.com/2011/02/cross-web-application-query-sharepoint.html

    and If that doesnt help you then try using SharePoint query classes

    CrossListQueryInfo and CrossListQueryCache.

    here is starting reference for you

    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.publishing.crosslistquerycache.aspx

    hope this helps you

     


    Warm Regards, Bhushan http://www.passionatetechie.blogspot.com
    Monday, August 22, 2011 5:26 AM

All replies

  • Hi,

    why dont you inherit the Content by Query web part and do the webUrl initiation at run time based on your requirement?

    or take a look at http://blog.mastykarz.nl/provisioning-content-query-web-part-querying-subsites-structured-repeatable-deployment/ for alternative approach

    hope this helps you


    Warm Regards, Bhushan http://www.passionatetechie.blogspot.com
    • Edited by Bhushan Gawale Thursday, August 18, 2011 6:49 AM added link
    Thursday, August 18, 2011 6:46 AM
  • Hi,

    You need to customize the the webpart with the CAML query,

    Refer this:

    http://msdn.microsoft.com/en-us/library/aa981241(v=office.12).aspx


    Thanks, Rahul Rashu
    Thursday, August 18, 2011 9:58 AM
  • Thanks Bhushan,

    it partially solved my problem. however in a scenario where i need to query data from different server webUrl wont help since it only takes serverRelative URLs

    it takes ~site or ~sitecollection as prefix so my scope gets restricted only to the site where CQWP is hosted.


    Ujwal Seli
    Thursday, August 18, 2011 11:17 AM
  • Rahul,

    i already tried using CAML but i dont think its possible to change your data source(weburl) of CQWP through CAML.


    Ujwal Seli
    Thursday, August 18, 2011 11:19 AM
  • Hi,

    If you want to do the cross web application or cross site collection queries then you cannot do this with out of the box CQWP.

    either you can try this blog post to achieve this , http://passionatetechie.blogspot.com/2011/02/cross-web-application-query-sharepoint.html

    and If that doesnt help you then try using SharePoint query classes

    CrossListQueryInfo and CrossListQueryCache.

    here is starting reference for you

    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.publishing.crosslistquerycache.aspx

    hope this helps you

     


    Warm Regards, Bhushan http://www.passionatetechie.blogspot.com
    Monday, August 22, 2011 5:26 AM