Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Is it possible to use the Content Query web part to filter on multiple specific content types that do not have a parent/child relationship?

I have a requirement to show Events (from a calendar) and Announcements (from an Announcement list) aggregated in the same area but as these come from two different branches in the content type tree, I can't do this via configuration of the web part.

Would I be able to do this with a custom CAML query after exporting/re-importing the web part xml? Also I noticed the following two XML clauses in the webpart.xml file:

<property name="ContentTypeName" type="string" />
<property name="ContentTypeBeginsWithId" type="string" />

Does anyone know if these can take multiple values and if so what is the format?

Are there any other implications to be aware of i.e. do the content types need the same site columns for the fields you want to display?

I'm looking to do this in SP2010 but would be interested to know if the same applied for MOSS.

share|improve this question
add comment

2 Answers

Hi I am trying the above solutions. I have 2 content types. I have to get data from Site Pages and Announcements list. So Site Pages has content type wiki page and Announcement has content type Announcement.

I am replacing the QueryOverride with the given content types. and then upload in webpart gallery and inserting same on a new page. But unfortunately I am getting data only from Site Pages and not from announcements. I checked I have data in Announcements List.

Please help, What I need to do. Asad Refai

share|improve this answer
add comment

I did need almost the same: select two sets of distinct contenttypes in a CQWP.

After some googling i found that you can override the query of the CQWP with your own CAML-query.

There is the information on msdn, hard to read and lacking complete examples. But that gave me a hint what to look for: QueryOveride and that led me to this msdn forum post which show this example to override the Query:

<property name="QueryOverride" type="string">
  <![CDATA[
    <Where>
      <Or>
        <Eq>
          <FieldRef Name="ContentType"/><Value Type="Text">Proposal</Value>
        </Eq>
        <Eq>
          <FieldRef Name="ContentType"/><Value Type="Text">Document</Value>
        </Eq>
      </Or>
    </Where>
  ]]>
</property>

Keep in mind that in the webpart xml no linebreaks can be used in the CAML.


Back to your question, besides the query override to select multiple contenttypes there is also a 'ListOverride' in which you can set multiple list:

<property name="ListsOverride" type="string">
  <![CDATA[
    <Lists>
      <List ID="81B49BFB-E218-46D4-A697-683FE7F286ED"/>
      <List ID="0CC1695B-1E54-45C5-9825-67DE219A2B4C"/>
    </Lists>
  ]]>
</property>

(snippet taken from this blog post with more CQWP hack/tweaks.)

share|improve this answer
    
Great thanks for your answer, I'll test it and mark your answer as correct if it works! :) –  Jonny Dec 20 '10 at 9:33
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.