September 30, 2011 02:41 PM

Building Custom WCM Sites with SharePoint 2010: #2 Use the Content By Query Web Part

Lesson 2: Display content with the Content by Query Web Part
SharePoint Pro
InstantDoc ID #140780
Rating: (1)
  • Example Web Parts in the Visio marketing website
  • How Content By Query Web Parts behave
  • Functionality will break if lockdown feature is enabled
  • Target all links to publishing pages
Lesson 2: Using the Content By Query Web Part

Although the Content By Query Web Part hasn’t changed much in SharePoint 2010, it still remains a very powerful tool that you can use to display content in a compelling way. The Lync marketing site in the screenshot below uses the Content By Query Web Part to display product-related videos.

Baginski WCM Fig3_0



The section of the page with the red box around it displays videos stored in a SharePoint list. When a user clicks the arrows at either end of the video list, the Web Part brings the next video into view and asynchronously loads the corresponding image, as the next screenshot shows.

Baginski WCM Fig4_0

The product video section employs an out-of-the-box Content By Query Web Part that uses custom Extensible Style Language (XSL) code to format the data it displays. The scrolling effect is accomplished with JQuery.

In more complex scenarios, you can develop custom Web Parts that inherit from the Content By Query Web Part. A perfect example is the Web Parts in the Visio marketing website shot you see below.

Baginski WCM Fig5_0

The green box highlights an out-of-the-box Content By Query Web Part configured to display sorting criteria and apply them to the page.

The two red boxes highlight custom Web Parts that inherit from the Content By Query Web Part. The custom Web Part on the left provides metadata-based filtering capabilities. It queries the SharePoint Managed Metadata Service to retrieve and display terms in the term store for the content on the page.

The custom Web Part on the right displays the filtered items. All three Web Parts on the page use custom XSL code to define their look and feel.

It’s important to understand how Content By Query Web Parts behave in anonymous access scenarios.

First, be aware that you shouldn’t link to specific list items from Content By Query Web Parts because the ability for anonymous users to view form pages isn’t enabled, even when anonymous access is enabled on the SharePoint website. However, you can turn on this functionality programmatically.

You also need to be aware that the Content By Query Web Part’s CopyUtil functionality will break if the lockdown feature is enabled. (CopyUtil.aspx is found under the _layouts virtual directory.)

To work around this problem, target all the links in your Content Query Web Part to publishing pages in your SharePoint websites.

See Lesson 3 from Todd Baginski: Learn How to Allow Anonymous Users to Rate Content
Go to Lesson 1: Pay Attention to Page Size
Check out Todd's back story on how he learned this.

Related Content:

ARTICLE TOOLS

   
Comments
    There are no comments to display. Be the first one!
You must log on before posting a comment.

Are you a new visitor? Register Here
   
   

Dan Holme's Viewpoint on SharePoint Blog

Office 365 Plan for Pain

With cloud services, even Office 365, what you don’t know about your cloud service can hurt you,...

SharePoint News and Products

Let SharePoint Be SharePoint: Making Social Collaboration Secure

Hesitant about unleashing SharePoint's social features? SharePoint security vendors aim to help....

Dan Holme's Viewpoint on SharePoint Blog

Microsoft SkyDrive Updates in the News

Microsoft's cloud storage, sharing, and collaboration platform for Windows Live is updated,...