Using Content Query Web part

Hi

I am using MOSS 2007 RTM version. I want to use CQ web part to display all sites under sitedirectory.

What list type should I select while doing this? I tried links and custom list but that did not returned any result.

Can someone please help me with this?

Thanks

Amit

[310 byte] By [AmitV] at [2008-2-20]
# 1

Hi Amit, the Content Query web part shows list and library items, not sites. You may want to look into the Table of Contents web part if you're interested in showing sites.

--George Perantatos [MSFT]

GeorgePerantatos at 2007-9-5 > top of Msdn Tech,SharePoint Products and Technologies,SharePoint - Design and Customization...
# 2

Hi George

Thanks for your reply.

I looked at the Table of Contents web part. This web part will not help in my requirements as our client wants to Display sites group by their status and also wants to filter that sites list based on metadata.

Can this be doable using out of the box web part or do I need to write a custom web part for that?

Regards

Amit

AmitV at 2007-9-5 > top of Msdn Tech,SharePoint Products and Technologies,SharePoint - Design and Customization...
# 3

Hi Amit,
the list you are looking for is can be easily found when you select source: "Show items from the following list" and then click Browse. You can navigate to your site directory then and select the Sites list from your SiteDirectory.

The problem is, that this list seems to have a special list type so that I didn't manage to configure the list type so that any data was found. It seems that MS doesn't want that list to be queried.

You can see that it is a special list type by looking at the database

SELECT tp_Title, tp_BaseType, tp_ServerTemplate, tp_RootFolder, tp_Template, tp_ItemCount, tp_Description
FROM AllLists
ORDER BY tp_ServerTemplate

You will see tp_ServerTemplate = 300 for this list whereas all user generated lists have a ServerTemplateID between 100 and 199.

Other special lists like the Pages library also have high ServerTemplateIDs.

Best regards

Ren

RenPeinl at 2007-9-5 > top of Msdn Tech,SharePoint Products and Technologies,SharePoint - Design and Customization...
# 4

Hi Ren

Thanks for your reply. I think you are right, CQWP is not built to query Sites list.

Best Regards

Amit

AmitV at 2007-9-5 > top of Msdn Tech,SharePoint Products and Technologies,SharePoint - Design and Customization...
# 5

Hi Amit,

I am trying to do the same thing your are and have been (partially) successful. I didn't want to do a custom web-part when this one seemed to be so close to what I wanted.

The thing I had to do to finally get the 'Sites' list to show up was to modify the properties of the web part. If you add the content query to your page, then 'export', you will get a .webpart file that you can modify in any text editor.

You have to change the ListsOverride property so that instead of looking for the list types in the drop-down by default, it looks for the Sites list type. This is what my property name line looks like:

<property name="ListsOverride" type="string">ServerTemplate="300"</property>

I think that was somewhat mentioned in a previous poster.

Now, the challenge I'm having is getting webpart to filter on some custom fields that I added to the 'Sites' list (like Cost Center). I can get the field to show up in the filter drop-down list by updating this property:

<property name="AdditionalFilterFields" type="string">URL;DivisionMulti,Division;RegionMulti,Region;Cost_x0020_Center,CostCenter</property>

...incidentally, this also adds the URL, Division, and Region fields. The webpart filter works for URL, Division, and Region, but not my custom field Cost Center (returns no results).

This only gets you part of the way, you have to update the Itemstyle.xsl sheet to show the Sites columns in the web part. Here's a good instruction for this:

http://msdn2.microsoft.com/en-us/library/bb447557.aspx

...you also need to include the following custom property line if you want any of these extra fields to show up in your xsl

<property name="CommonViewFields" type="string">URL,URL;DivisionMulti,Choice;RegionMulti,Choice;Cost_x0020_Center,Text</property>

If anyone has any info about my custom field filter not returning the expected results, I would be happy to hear from you.

HTH

-James

jmgscott at 2007-9-5 > top of Msdn Tech,SharePoint Products and Technologies,SharePoint - Design and Customization...
# 6

Thanks for the post..

I followed your instructions, but when I import the web part, I get a display that looks like this

HarryMan at 2007-9-5 > top of Msdn Tech,SharePoint Products and Technologies,SharePoint - Design and Customization...
# 7

Ok, you're almost there. You just have to change the ItemStyle.xsl file (best to do it with SP Designer) and add a new style that will display the contents of the Sites list.

Here are a couple of good sites for learning how to do this:

http://www.heathersolomon.com/blog/articles/CustomItemStyle.aspx

http://msdn2.microsoft.com/en-us/library/bb447557.aspx

My style looked like this:

Code Snippet
<xsl:template name="Sites" match="Row[@Style='Sites']" mode="itemstyle">
<xsl:variable name="DisplayTitle">
<xsl:call-template name="OuterTemplate.GetTitle">
<xsl:with-param name="Title" select="Title"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="SiteUrl">
<xsl:call-template name="OuterTemplate.GetSafeStaticUrl">
<xsl:with-param name="UrlColumnName" select="'URL'"/>
</xsl:call-template>
</xsl:variable>
<div id="linkitem" class="item">
<div class="link-item">
<div class="LinkInfo">
<a href="{$SiteUrl}"><xsl:value-of select="@Title"/></a>
</div>
</div>
</div>
</xsl:template>

To get this to work you have to modify the CommonViewFields property of the webpart like this:

<property name="CommonViewFields" type="string">URL,URL;</property>

The URL that is given will be the actual URL to the site, not what you were seeing before.

Read the links I sent if you want to add more columns to the HTML that displays.

HTH

jmgscott at 2007-9-5 > top of Msdn Tech,SharePoint Products and Technologies,SharePoint - Design and Customization...
# 8

> If anyone has any info about my custom field filter not returning the expected results, I would be happy to hear from you.

We are having the exact same concern. By creating custom column and trying to filter on that custom column does not return the correct / expected results in the content query web part.

Any replies would be appreciated - please post back to the forum or email nilesh_kelkar @ hotmail . com & I will post it back.

NK

NileshKelkar at 2007-9-5 > top of Msdn Tech,SharePoint Products and Technologies,SharePoint - Design and Customization...
# 9
What is the field type that you are using that is not working? Mine is working with a Choice field, but for some reason it's just the straight Text field that is not working.
jmgscott at 2007-9-5 > top of Msdn Tech,SharePoint Products and Technologies,SharePoint - Design and Customization...
# 10

Has anyone knows how to define "List Title" in ItemStyle.xsl ?

Thanks.

BR,

Ellitt

Ellitt at 2007-9-5 > top of Msdn Tech,SharePoint Products and Technologies,SharePoint - Design and Customization...
# 11

What content type is being used? After modifying the ServerTemplate value, I still have to select a content type and none appears to return only my sites.

Thanks.

T

TBone_350 at 2007-9-5 > top of Msdn Tech,SharePoint Products and Technologies,SharePoint - Design and Customization...

SharePoint Products and Technologies

Site Classified