Archive

Posts Tagged ‘CQWP’

Using Content Query WebPart to display Files from a specific folder

July 22, 2011 4 comments

Content Query Web Part (CQWP) is a powerful tool to aggregate and display content from different sources. It also allows you to modify the presentation of your content through XSLT transformation to almost any design you like.

In this post I would like to show you how you can display documents/items from a specific folder in your document library.

In my use case I have a document library with two folders “news” and “old”. 
Folder “News” contains two documents “News 1.txt” and “News 2.txt”. Folder “Old” contains also two files “Old 1.txt” and “Old 2.txt”. There is also a file “root document.txt” which is stored directly in the document library.

Our goal is to display only the documents from “news” folder on our portal landing page. At the end of this exercise we should see only “News 1.txt” and “News 2.txt” in the CQWP.

Default view of the document library for this exercise:

image

 

Adding CQWP web part to the landing page

First of all we need to place our CQWP on the landing page of our SharePoint site.

  1. Edit your page

    image

  2. Select “Insert” tab from the SharePoint Ribbon

    image

  3. Click on the “Web Part” and add Content Query Web Part

    If you can not find the “Content Query” Webpart in the “Content Rollup” Category make sure that the “SharePoint Server Publishing Infrastructure” feature in site collection features is activated.

    image

    Configuring the query for CQWP

    After we placed the CQWP on our landing page we need to set up the query to display particular content. 

    To set up the query edit the web part and expand the “Query” node in the settings panel. Select the document library where your document are stored. In my case I will use “Shared Documents” library.

    Leave the settings for “List Type” and “Content Type” as they are:

image

    After clicking “Apply” button you should see all documents and folders from your document library in your CQWP:

    image

    Now you need to setup “Additional Filters” to show only documents from “news” folder.

    Select “URL Path” from the drop down. Set “contains” as condition and “/news/” as value for your filter. (“news” is the name of the folder where our target documents are stored)

    image

    If you can not find “URL Path” in the drop down, make sure that “Content Type” is set to “<All Content Types>”

    Click “OK” or “Apply” and you will see only documents from the “news” folder:

    image

    Advertisements
    Categories: SharePoint Tags: