Query for content types similar to CQWP?

Aug 7, 2012 at 2:21 PM
Edited Aug 7, 2012 at 2:22 PM

Hi all.  I'm new to the library, and already love it!  I have this very general Content By Query WebPart that queries for 2 different content type throughout all my sites and displays info like Title, Subtitle, etc.  The CQWP is embedded into a template and the template sits at the root site.  From what I can see with the SPServices library I basically need to query all the Pages library for each site.  However, that just doesn't sound too efficient.  Is this same sort of functionality possible with SPServices, and if so can someone point me in the right direction?  Thanks.



<PublishingWebControls:ContentByQueryWebPart id="..." runat="server" 
	ChromeType="None" WebPart="true" Height="" Width=""
	AllowConnect="false" AllowEdit="false" AllowHide="false" AllowMinimize="false"
	AllowRemove="false" AllowZoneChange="false" AllowClose="false" 
	Title="Events" PageSize="-1" ItemLimit="5" ItemStyle="EventActionItem"
	QueryOverride="<Where><And><Or><BeginsWith><FieldRef Name='ContentTypeId' /><Value Type='ContentTypeId'>0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900DD0126D65DE8404CB540571DFA751B850304</Value></BeginsWith><BeginsWith><FieldRef Name='ContentTypeId' /><Value Type='ContentTypeId'>0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900DD0126D65DE8404CB540571DFA751B850302</Value></BeginsWith></Or><Geq><FieldRef ID='{6d2bf694-d40f-4a64-8d75-e5ae571068d9}' Type='DateTime' /><Value Type='DateTime' IncludeTimeValue='TRUE'><Today /></Value></Geq></And></Where><OrderBy><FieldRef ID='{d9bca956-8948-4a04-be01-f9a889af7121}' Ascending='TRUE' Type='DateTime' /></OrderBy>"
Aug 9, 2012 at 1:11 PM

Anyone have any pointers for me here?  As I said, it looks like I need to query the pages library for each subsite, but that just seems very inefficient.  I basically need to do a query for a content type used throughout the entire application and display pieces of information from it.

Aug 9, 2012 at 1:57 PM

You're right: with SPServices you'll need to traverse the site topology if you use GetListItems. However, have you thought about using the Search Web Service? If the content is definable in a query, then it may be a much better way to go.

I also use Data View Web Parts (DVWPs) with DataSourceMode="CrossList" for this sort of thing.


Aug 9, 2012 at 2:32 PM

Thanks for the reply!  Yeah, I played with the Search Service a bit, that's a great idea!  I'm assuming I would need to use the SQL query version to fit what I need?  I'm using the library to build a jquery mobile site so I really don't want to embed CQWP's or DVWP's into my mobile pages to avoid the additional markup from these web parts.

Aug 9, 2012 at 3:58 PM


You don't need to write SQL Queries to pull that off.  Search has a web service that Marc has already wrapped.  An excellent post on using the Search web service can be found here: