Community Central User’s Guide, Part 1: How to Create a Custom Web Part to Display Scoring Statistics

Bamboo’s Community Central application provides a number of capabilities that enhance and extend the social features available in SharePoint out-of-the-box. Additionally, users can create, through customization, a new system of scoring user activities that goes beyond the statistics which are already tracked by default (e.g., Top Experts, or Most Active Users). For example, your organization may have a desire or need to track something else, such as Most Helpful Users or Most Suggested Users.

Perhaps your organization is looking to increase user participation and runs a contest (with a suitably desirable prize, such as an extra vacation day) to encourage suggestions. The Manage Scoring rule list lets an administrator set points for each category. There are defaults in place, but administrators have the ability to add custom settings. For example, we provide the default Top Experts (the people who provided the answers, with the answers verified by the people who asked the questions). Your organization may not care about the Top Experts, but would rather see the Top Suggested as an Answer for the purposes of the contest. This post will show you how to do so, using two different methods: creating a New View for the Web Part properties or making modifications using SharePoint Designer.

The scoring information can be tracked and validated based on Site Members and the site activities that they participate in. This feature allows us to track statistics based on who creates and responds to the discussion board’s topics, and we track five specific user activities: create a new forum topic, post a reply to a topic, author’s post is verified as an answer, author’s post is suggested as Answer, and verify Answer from Suggested. In this article, we’ll show users how to create a new List View Web Part of a Site Members list to display additional statistics, based on user activities and scoring rules. This can be accomplished in two different ways:

  • Change Using Web Part Properties
  • Change Using SharePoint Designer

Change Using Web Part Properties:

1. Create a new view for the List Members titled Most Suggested View with the following sorting and filtering properties:

2. Edit the Forum site page. In the Web Part Gallery, add the List Members Web Part to the page:

3. Modify an existing xslt and create a new xslt.

  • Go to the site to which you want to add the Web Part. From the Skin folder, download the xslt file (in this example, we’re using the file: Bamboo.Expert.xslt) to your local desktop:
  • Rename Bamboo.TopExperts.xslt to Bamboo.MostSuggested.xslt.
  • Edit the Bamboo.most suggested.xslt and replace NumberofAnswerVerified with NumberofAnswerSuggested:
  • Upload the new Bamboo most suggested.xslt to the Skin folder.

4. Edit the Web Part: Change the title to Most Suggested and change the Selected View to Most Suggested View. In addition, make sure that the XSL Link points to Skin/Xsl/Bamboo.most suggested.xslt. Click Apply and OK:

5. The Web Part will now display as follows:

Change Using SharePoint Designer:

1. Modify an existing xslt and create a new xslt.

  • Go to the site to which you want to add the Web Part. From the Skin folder, download the xslt file (in this example, we’re using the file: Bamboo.Expert.xslt) to your local desktop:
  • Rename Bamboo.TopExperts.xslt to Bamboo.MostSuggested.xslt.
  • Edit the Bamboo.most suggested.xslt and replace NumberofAnswerVerified with NumberofAnswerSuggested:
  • Upload the new Bamboo.most suggested.xslt file to the Skin folder.

2. Edit the Forum site page. In the Web Part Gallery, add the List Members Web Part to the page:

3. Open the site in SharePoint Designer. From All Files in the left navigation, click default.aspx to open the page:

  • In Split mode, go to the Web Part that you just added and click on default.aspx. Hover your mouse over the Web Part you just added. On the code area, it will be highlighted. You should see the following line in your code:
   1: <View Name="{xxxxx-xxxxx-xxxx-xxxx-xxxxx}"  MobileView="TRUE" Type="HTML" Hidden="TRUE" TabularView="FALSE" OrderedView="TRUE" DisplayName="" Url="/SA15/Engineering Forum/default.aspx" Level="1" BaseViewID="0" ContentTypeID="0x">
   2:
  • Change the BaseViewID=”x” to BaseViewID=”0″. BaseViewID=”0″ will prompt the application to use the custom view.
  • Next, find the title attribute and change to it to your new title. For this example, we’re using the title Most Suggested.
  • Change the OrderBy and the ViewFields to filter the data for most suggested. To do this, replace the lines from <Query> to </View>. You will also need to order the NumberOfAsnswerSuggested field and get a value greater than 0.
   1: <Query>
   2: <OrderBy>
   3: <FieldRef Name="NumberOfAnswerSuggested" Ascending="FALSE"/>
   4: </OrderBy>
   5: <Where>
   6: <Gt>
   7: <FieldRef Name="NumberOfAnswerSuggested"/>
   8: <Value Type="Text">0</Value>
   9: </Gt>
  10: </Where>
  11: </Query>
  12: <ViewFields>
  13: <FieldRef Name="Member"/>
  14: <FieldRef Name="Point"/>
  15: <FieldRef Name="NumberOfAnswerSuggested"/>
  16: </ViewFields>
  17: <RowLimit Paged="TRUE">10</RowLimit>
  18: <Aggregations Value="Off"/>
  19: <Toolbar Type="Standard"/>
  20: </View>
  • Under the tag </XmlDefinition>, add this tag to use the new xslt:

<XslLink>Skin/Xsl/Bamboo.MostSuggested.xslt</XslLink>

  • Save the page in SharePoint Designer and refresh the page from the browser. You will now see that the following changes have been implemented:

Continue reading the Community Central User’s Guide.