Roll Up Blog Posts in a Site Collection

I got a quick question today from a client asking how to roll up blog posts.  He wanted to display the latest blog posts from all of the blogs which executives have in the Site Collection, which is used as the organization’s Intranet.

He had the idea right, using a Data View Web Part (DVWP) with the DataSourceMode=”Crosslist” and the Webs Scope=”SiteCollection”.  However, he got trapped by a cut and paste gotcha.

Since he wanted to only show the latest blog posts, he needed to set the correct value for ServerTemplate.  The CAML he had copied had <Lists ServerTemplate=’104′></Lists>, which specifies lists which are based on the ‘Announcements list’ template.  The value for the ‘Blog posts’ template is <Lists ServerTemplate=’301′></Lists>.

The possible values for ServerTemplate can be found in this MSDN support article, and here they are listed for ease of use:

  • 100   Generic list (this means any Custom List)
  • 101   Document library
  • 102   Survey
  • 103   Links list
  • 104   Announcements list
  • 105   Contacts list
  • 106   Events list
  • 107   Tasks list
  • 108   Discussion board
  • 109   Picture library
  • 110   Data sources
  • 111   Site template gallery
  • 112   User Information list
  • 113   Web Part gallery
  • 114   List template gallery
  • 115   XML Form library
  • 116   Master pages gallery
  • 117   No-Code Workflows
  • 118   Custom Workflow Process
  • 119   Wiki Page library
  • 120   Custom grid for a list
  • 130   Data Connection library
  • 140   Workflow History
  • 150   Gantt Tasks list
  • 200   Meeting Series list
  • 201   Meeting Agenda list
  • 202   Meeting Attendees list
  • 204   Meeting Decisions list
  • 207   Meeting Objectives list
  • 210   Meeting text box
  • 211   Meeting Things To Bring list
  • 212   Meeting Workspace Pages list
  • 301   Blog Posts list
  • 302   Blog Comments list
  • 303   Blog Categories list
  • 1100   Issue tracking
  • 1200   Administrator tasks list

16 Comments

  1. In a “Records” site I have a “Documents” library which has a “Project” column. In a “Projects” site I have a “Projects” list which has both a “Project” and a “ProjectStatus” column (choices are Active and Inactive). I am trying to create a view in the “Documents” library which only shows items with “Active” projects. After reading your blog posts about crosslist queries, I think i’m out of luck and will need to add the “ProjectStatus” column to the “Documents” library. Any thoughts on the possiblity of creating such a view without adding a column to the “Documents” library? thanks

    Reply
    • Dan:

      From what you explain, you don’t need Crosslist mode. What you can do is set up a DVWP which has an Aggregate Data Source with your Documents and Projects lists. Then you can “join” (though it’s not a real join) on the Project column, assuming that the values match.

      M.

      Reply
      • thanks for the quick reply. After a few more searches and reviewing your other posts (as well as those of Laura Rogers which you pointed to) I’ve got something almost working. In your “right” way post, you mention adding a where clause to filter the results – I think this is what I want to do as I only want to show “Documents” from “Projects” which have a ProjectStatus=Active (a column in the Projects list). If I understand you correctly I would change the selectcommand for the “Projects” datasource in the _catalogs/fpdatasources xml file for the linked datasource. After adding the following, the results still show documents for projects which are not “Active”. Have I missed something (or rather I must have missed something) – can you point me in the right direction again? thanks

        selectcommand=”<View>Active</View>”

        Reply
        • Dan:

          The SelectCommand needs to contain CAML. You can either build up the CAML by applying filters in the DVWP Common Data View Tasks (or manually in the code) or manage the filtering in the XSL for the DVWP. Which you choose ought to depend on which you are more comfortable with.

          You can add filtering to the Rows selection by adding the clause in square brackets. (I’d paste an example here, but code doesn’t ever “take” in these comments.) It sounds like you’ve looked at this post? http://sympmarc.com/2009/07/24/the-right-way-to-join-two-lists-in-a-dvwp/

          You shouldn’t edit the datasources in the _catalogs/fpdatasources folder. Those are the stored definitions which are created if you save a datasource link, but the code for the DVWP you are working with is already in the page. (The _catalogs/fpdatasources XML files are used to instantiate the DVWP initially.)

          M.

          Reply
          • ok, I started over from scratch and have a working view with 5 columns from the “Documents” library and 1 column from the “Projects” list (D1, D2, D3, D4, D5, P1), with a join between D5 from “Documents” and “Title” from “Projects” (P1 is “ProjectStatus” from “Projects”). For my test data I have one record which is “Active” and one record which is “Inactive”. In my view I only want to see records with a “ProjectStatus” = “Active”. I first tried to applying a filter throuth the Common Data View Tasks, which added criteria in brackets on the rows (i’m hoping code comes through)
            variable name=”Rows” select=”/dsQueryResponse/CPD_Documents/Rows/Row[@ProjectStatus=’Active’]” However, when I do that I don’t get any records. I then tried adding CAML to the selectcommand (this time on the page, not in the _catalogs folder). When I do that, I still get two records, but the value for P1 is empty for the record which has an Inactive project. It seems I need to add my filter condition to the “join”. Is that possible? Or is it possible to create a linked data source to a View rather than the list itself? And again, thanks for your insight and assistance.

            Reply
  2. Hi Marc,

    Thanks a lot for your posts regarding the usage of CrossList with the DVWP. That’s work fine for me.
    In the current post, you speak about the ability to get only the LATEST post from all the blogs from a site collection. I’m able to retrieve ALL the posts sorted by Publishing date and limit the display to ‘n’ items, but i don’t kwow how i can select only one post (the latest) from each blog.
    Any idea ?

    thank you very much.

    a french guy !
    Gerald

    Reply
      • Great job with your articles “Unlocking the Mysteries of Data View Web Part XSL Tags” !
        As you told me, i use a first sort on the list location (FileDirRef field) and finally a sort on the Published date (PublishedDate field) in the CAML. so i’m able to remove duplicate row with the ddwrt:Namechanged in the xslt and that works!
        I can retrieve the lastest post of each blog.

        But…. the result is displayed sorted by blog location and i would like to display the result list sorted by published date… And that seems not so easy to do.

        Your posts are very interesting and i continue to read them. Hope to find the solution.
        Any tips are welcome.

        Regards

        Reply
  3. Hi Marc,

    I also have a question regarding the combination of crosslist mode and linked data sources.
    I have 2 lists, List A that has instances in multiple subsites of a site collection and List B that exists only at the top level.

    I need to perform a crosslist rollup of all the List A’s in the site collection and reference columns in List B.

    Thanks in advance Marc,
    Jason

    Reply
    • I think what you’ll need is an AggregateDataSource with ListA having DataSourceMode=”CrossList” and ListB having DataSourceMode=”List”. Then in your XSL, you’ll need to build the cross-reference between the ListA items and the ListB items.

      M.

      Reply
  4. I am trying to display pages in pages library.

    I am seeing the row count is > 1000 but i can’t display even the name field on the view.

    Any ideas why this could happen?

    Reply
  5. Hi Marc,

    whatever i add the return datafields are changed to the below fields only

    @ListId,ListId;@WebId,WebId;@ID,ID;

    the query i have is

    I just want to diaply “Title” i cant even display that. I have used the same configuration for Workflow Tasks list and it worked.

    But Pages library it is working but cant see any details they are all blank.

    Thanks in advance,
    Soujanya

    Reply

Have a thought or opinion?