in

SharePoint Blogs

The Best Place for SharePoint-related Blogs

Ton Stegeman [MVP] weblog

October 2007 - Posts

  • Introducing the Content By Type webpart

    Update 07–11–2007: The beta period is now closed. I will continue to work on the feedback of users who are currently testing the webpart. On my new weblog I will post the updates and the 1.0 release in the coming weeks.

    I have been working on a new web part that aggregates content of a specific content type into a gridview. Much like the Content Query web part, but easier to use by end-users. They just need to select the content type and the columns they want to be displayed (that’s why I called it “Content by Type”).

    The most important features are:

    – Works in WSS and MOSS
    – Casting / formatting of column data types
    – Links to items and its context in contextmenu
    – Links to lookup / person fields
    – Filter items using MOSS filter web parts
    – Supports grouping/sorting and paging

    Image001

    The screenshot above shows the Content By Type webpart in action. The view displays 4 columns of this content type. The view is grouped by content type and sorted by Modified date. When configuring the webpart, users simply choose a content type and the web part lets them pick the columns they want. The screenshot below shows part of the configuration. Users can (un)select the available content type fields and configure the links for these fields. After configuring the other web part properties (scope, grouping, sorting, list type, etc.) the web part will query for items that match the selected content type(s) and display the results in a grid.
    Image003

  • Export user information to Excel using "Export to spreadsheet" in SharePoint 2007

    In mosts lists in SharePoint the Actions menu has an option “Export to spreadsheet”. Using this option you can easily export the contents of the current view to an Excel spreadsheet.I got the question why this link is not available in the User Information list. This is the list that you can access from “People and Groups” – “All People”.

         Userinfo1

    The  Actions menu on this page does not have the option “Export to spreadsheet”. You can still export the content of this list by using the url below:

    http://[SITEURL]/_vti_bin/owssvr.dll?CS=109&Using=_layouts/query.iqy&List=[LISTID]&View=[VIEWID]&CacheControl=1

    In this url, you will need to change these 3 options:

    • [SITEURL] – the url of your top level site
    • [LISTID] – The Guid of the User Information List
    • [VIEWID] – The Guid of the view that you want to export.

    The easiest way to get the [LISTID] and [VIEWID] is to select “List Settings” in the “Settings” menu from the screenshot above. First you need to configure a view to have the columns and filters etc. to get the users that you want to export. This is exactly the same process as in any other SharePoint list. While you are configuring your view, the address bar of your browser contains the IDs that you will need:

         Userinfo2

    Copy the List and View querystring parameters from this url to the url mentioned above.

    Then copy the full url with all correct values in your browser address bar, and the user information will show up in Excel:

         Userinfo3

    In my case the full url looks like this:

    http://office2007/_vti_bin/owssvr.dll?CS=109&Using=_layouts/query.iqy&List=%7B299130F0%2D2E0B%2D4A02%2D8AF0%2D43BA54C79B28%7D&View=%7B45A446EB%2DCFA4%2D4DEE%2D8616%2D5B43AFBC7B31%7D&CacheControl=1

    At this point I thought, I might as well create a feature that add this action as an item to the Actions menu for the list. So I created a feature file and an elements file and added a “CustomAction” element. I set the RegistrationType to List and the RegistrationId to 112, which is the list template type id for this list. After registering and activating the feature, my new menu item did not show up in the actions menu. It looks like this list looks like a normal SharePoint list, but it is not 100%. Although the first screenshot shows an Actions and Settings menu, these items seem not to be created as in all the other lists. If you go to the List Settings of the list, select one of the views and click OK, you will see this screenshot:

         Userinfo4

    It looks like the normal Toolbar was removed from the list schema and the menus are added in another way. The difference is that in the screenshot above, we are in the page /_catalogs/users/simple.aspx and in the first screenshot we are on page /_layouts/people.aspx. This people.aspx page contains the menu items for our actions menu. Because it is not recommended to change the SharePoint pages directly, I gave up trying to add my item to the Actions menu.

    Instead I created an item in the site settings page. In the “Users and Permissions” sections users now have an opion “Export User Information”:

       Userinfo5

    The XML file for my feature:

    <Feature 
      xmlns="http://schemas.microsoft.com/sharepoint/"
      Id="E9189036-3847-4D63-8A13-483FDAE44973"
      Title="Export User Information to spreadsheet"
      Description="Menu item to export user information to a spreadsheet."
      Scope="Site">
      <ElementManifests>
        <ElementManifest Location="elements.xml" />
      </ElementManifests>
    </Feature>

    And the XML file for the elements.xml file: Please note that you will need to replace [LISTID] and [VIEWID] with the appropriate values (see above)

    <?xml version="1.0" encoding="utf-8" ?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
      <CustomAction Id="ADD173BC-C9B2-48EE-A1AF-3529C2338C06"
          GroupId="UsersAndPermissions"
          Location="Microsoft.SharePoint.SiteSettings"
          Sequence="100"
        Title="Export User Information"
          Description="Export User Information to spreadsheet.">
        <UrlAction Url="/_vti_bin/owssvr.dll?CS=109&amp;Using=_layouts/query.iqy&amp;List=[LISTID]&amp;View=[VIEWID]&amp;CacheControl=1"/>
      </CustomAction>
    </Elements>

    After installing and activating the feature at the site collection features, the menu option is available.


Need SharePoint Training? Attend a SharePoint Bootcamp!

Posts (c) their respective authors. Everything else (c) 2007 SharePoint Experts