in

SharePoint Blogs

The Best Place for SharePoint-related Blogs

MdP's MOSS Blog

You want it to do what?

Overriding the Content Query Web Part

Out of the box, the content query web part can only get items from one content type, but what happens if you want it to display items from more than one content type?  You don't have to write a custom web part to do this thanks to Microsoft adding overrides in their content query web part. 

First, build the CQWP (Content Query Web Part) with everything how you want it, including the query, then you will need to export it to a location on your drive.  To export the web part, navigate to the page that contains the web part.  Open up the page in edit mode and on that page, click on the edit drop down menu for the web part and click "Export."

Save the file locally.  Once you have exported the web part as a .webpart file, open it with notepad and edit the ListsOverride property.

If you want to get everything based on a Generic List (BaseType = 0), you would use the following property:

 <property name="ListsOverride" type="string"><![CDATA[ <Lists BaseType="0"> </Lists>]]></property>


 
If you want to get everything based on a document library (BaseType = 1), you would use the following property:

 <property name="ListsOverride" type="string"><![CDATA[ <Lists BaseType="1"> </Lists>]]></property>

 Once you have finished editting the webpart, save the file.  Now we have to import the new .webpart file.  To do this, go to "Site Actions" -> "Site Settings" -> "Modify All Site Settings" on the top level site.

 Under "Galleries", click on "Web Parts".  Now click the "Upload" button.

Click on the "Browse" button and select the .webpart file that you made changes to.

Now set all of the properties for the webpart and click "OK" when finished.

Now browse to the page you want to add the web part to.  Open up the page in edit mode and in the web part zone where you want to add the web part, click on "Add a web part" and select your new webpart and then click "Add."

How to: Customize the Content Query Web Part by using Custom Properties
http://msdn2.microsoft.com/en-us/library/aa981241.aspx

 

 

 

Comments

 

Mike Walsh's WSS and more said:

July 1, 2007 1:36 AM
 

Ricc said:

Awsome tip. havn't tested it yet but think that will help a lot!!!!

July 2, 2007 8:19 AM
 

Links (7/1/2007) « Steve Pietrek’s SharePoint Stuff said:

Pingback from  Links (7/1/2007) &laquo; Steve Pietrek&#8217;s SharePoint Stuff

July 2, 2007 9:21 AM
 

Boris-Schapira.com » 3 liens pour aller plus loin avec le Content Query Web Part said:

Pingback from  Boris-Schapira.com  &raquo; 3 liens pour aller plus loin avec le Content Query Web Part

July 9, 2007 8:01 AM
 

Nitya said:

informative

July 17, 2007 1:55 AM
 

Philippe Sentenac [Usual Coder] said:

Aujourd'***, je vais profiter de vous donner quelques informations sur la customization de la content

October 12, 2007 8:54 AM
 

Stacey Bailey said:

I've done this to create my own Calendar, Announcement, Task, and Issues rollup web parts so I can reference all of the fields common to those list types in my cqwp itemstyle xslt.  

I'd like to make these web parts available across my entire farm, but don't want to have to upload separately into each site collection gallery.

Is there a way to deploy these .webpart files with stsadm directly or to package them up as solutions?

April 22, 2008 1:16 PM
 

mdp said:

You can deploy webparts using features if you follow these instructions.  You can deploy the features to each site collection and it will require a lot less work

www.sharepointnutsandbolts.com/.../deploying-web-parts-as-feature.html

For future reference, please check out my new blog at:
http://www.thesug.org/blogs/mossmania

April 22, 2008 1:47 PM
 

How to customize the Content Query Web Part XSL to aggregate blog posts « The Art of SharePoint Evolution said:

Pingback from  How to customize the Content Query Web Part XSL to aggregate blog posts &laquo; The Art of SharePoint Evolution

June 15, 2008 9:00 PM

Leave a Comment

(required )  
(optional )
(required )  
Add

Need SharePoint Training? Attend a SharePoint Bootcamp!

Posts (c) their respective authors. Everything else (c) 2007 SharePoint Experts