Rollup Blog Posts in WSS 

Tags: How To, Blog, Social, SharePoint Designer, Pre SharePoint 2010, Branding, Public Facing Site

I've created my main site with two blog subsites. I want to show the last 5 "recent" (under 90 days) posts on the main page of the main site. A Content Query Web Part would be perfect here, but unfortunately, that is only available in MOSS. There is an Enhanced Content Query Web Part on CodePlex, but it derives from the CQWP which still requires MOSS. Fortunately, SharePoint designer has a DataFormWebPart which can perform the rollup.

Here are the steps.

  1. Open the page where you want the roll up in SharePoint Designer.
  2. Optional - If you are unfamiliar with this process, you may want to create this is in a test page, and then copy it to the real page later.
    1. Create a Pages document library if it does not already exist
    2. Site Actions > Create > Web Part Page
    3. Name: Pages
    4. Don't display on Quick Launch
    5. Document Template: Web Part Page
    6. In the Pages Document Library, create a new Web Part Page
  3. Create a Data Source
    1. Data View > Manage Data Sources … > Connect to another Library
    2. Enter your site name and URL when prompted
    3. You should be able to navigate to the Posts document library.
  4. In Split or Code mode, put the cursor where you want the data to appear. If you put it into an existing web part zone, you will be able to edit it within a web page as a web part. Note that the cursor should not be in an existing Web Part, such as a ContentEditorWebPart. It could also be within a <TD> or <Div>, etc.
  5. Data View > Insert DataView in the SPD menu.
  6. In the Data Source Library, choose Posts
  7. In the design pane of the page, enter the Common Data View tasks by clicking on the arrow in the upper-right corner of the DVWP.
    1. Set the filter Criteria to Approval Status Equals 'Approved'.
    2. Sort by Created Descending
    3. In Edit Columns, Use Title and Created
    4. In Properties > Paging > Limit the total number of items displayed to 5
  8. Make a link from the title field
    1. Hover over a title in the title field and click on the arrow
    2. Change the field type to a Hyperlink
    3. Leave the Text to display as {@Title}
    4. Clear out the Address text box dropdown
    5. Next to the Address text box dropdown, click the fx button > Path >OK
    6. Click fx > Id > OK. The address should be {@FileDirRef}{@ID}
    7. Click Ok to exit the dialog box.
    8. Switch to Code view in SharePoint Designer
    9. Replace {@FileDirRef}{@ID} with /{@FileDirRef}/Post.aspx?Id={@ID}
  9. Clean up
    1. The data is self-explanatory enough that we don't need the headers. I removed the entire row containing the <th> tags.

Besides limiting the number of posts in the rollup to five, I'd also like to show items that are not too stale, say no more than 90 days old. Here are the steps

  1. Select the DFWP Common Data View Tasks in the Design View > Filter
  2. Set Field Name to Created
  3. Set Comparison to Greater Than
  4. Set Value to Current Date
  5. In code view, find the reference to Today within the DFWP's select statement
  6. Change Today to Today OffsetDays='-90'

As I researched this, I came across this post that suggests we could have a roll up of posts from all subsites instead of two separate lists, but that's a project for another day perhaps.

Note that is was originally published 7/13/2008, but it got lost somehow.

 
Posted by AndyGett on 13-Jul-08
0 Comments  |  Trackback Url | Bookmark this post with:        
 

Comments

Name:
URL:
Email:
Comments: