Skip to content

Show rating stars in the content query web part

October 29, 2010
I’m not one to blow my own horn, but I have been ROCKING the content query web part as of late. I always stayed away from it in favour of the data view web part, believing it wasn’t as flexible, but as it turns out, I was mistaken.
Yesterday, I wanted a “top rated documents” web part for the home page of a document centre, that lists the top rated documents from all document libraries in the site. This is easy enough, using the content query web part (CQWP) with the following settings:
  • source = “show items in this site and all subsites”
  • list type = “document library”
  • additional filters: show items where Rating (0-5) is greater than 0
  • under presentation choose an item limit (10 in my case) and sort items by Rating (0-5) in descending order
So that’s nice and all but I would like to display the lovely wee stars beside my document titles so users can see the rating on each document.
If you change the item style (under presentation in the CQWP settings) to something like title and description, and then set the description field to the rating column you can see the raw data that is stored in there – just a number between 0 and 5 with a whole truckload of zeroes at the end.
So how is this rendered throughout other parts of SharePoint 2010 sites when you see the actual star image instead of the average rating data? It is done using CSS classes on both the image of the stars, and the link itself, and it’s all wrapped in a span tag. There’s also a heap of fancy javascript in there to give you the rollover effect and the ability to submit your own rating (but we’re not going to try and get that fancy today). The average ratings are calculated for this colum and can be any number from 0 to 5, including long decimal numbers, but the stars are only rendered in either whole number or whole number and a half ratings (e.g. an average rating of 3.335 shows 3.5 stars).
To use this ratings column in the CQWP and include the necessary tags wrapped around it, I added a custom item style to itemstyle.xsl (for an introduction on modifying itemstyle.xsl see Heather Soloman’s post) as per below:
    <xsl:template name="TitleAndRatings" match="Row[@Style='TitleAndRatings']" mode="itemstyle">
        <xsl:variable name="SafeLinkUrl">
            <xsl:call-template name="OuterTemplate.GetSafeLink">
                <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
        <xsl:variable name="DisplayTitle">
            <xsl:call-template name="OuterTemplate.GetTitle">
                <xsl:with-param name="Title" select="@Title"/>
                <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
      <div class="item link-item">
        <xsl:call-template name="OuterTemplate.CallPresenceStatusIconTemplate"/>
        <div style="float:right">
        <xsl:if test="@Ratings &gt;= 4.75">
			<a class="ms-currentRating"><img class="ms-rating_5" src="/_layouts/Images/Ratings.png" alt="Current average rating is 5 stars." /></a>
        <xsl:if test="@Ratings &gt;= 4.25 and @Ratings &lt; 4.75">
			<a class="ms-currentRating"><img class="ms-rating_4_5" src="/_layouts/Images/Ratings.png" alt="Current average rating is 4.5 stars." /></a>
        <xsl:if test="@Ratings &gt;= 3.75 and @Ratings &lt; 4.25">
			<a class="ms-currentRating"><img class="ms-rating_4" src="/_layouts/Images/Ratings.png" alt="Current average rating is 4 stars." /></a>
        <xsl:if test="@Ratings &gt;= 3.25 and @Ratings &lt; 3.75">
			<a class="ms-currentRating"><img class="ms-rating_3_5" src="/_layouts/Images/Ratings.png" alt="Current average rating is 3.5 stars." /></a>
        <xsl:if test="@Ratings &gt;= 2.75 and @Ratings &lt; 3.25">
			<a class="ms-currentRating"><img class="ms-rating_3" src="/_layouts/Images/Ratings.png" alt="Current average rating is 3 stars." /></a>
        <xsl:if test="@Ratings &gt;= 2.25 and @Ratings &lt; 2.75">
			<a class="ms-currentRating"><img class="ms-rating_2_5" src="/_layouts/Images/Ratings.png" alt="Current average rating is 2.5 stars." /></a>
        <xsl:if test="@Ratings &gt;= 1.75 and @Ratings &lt; 2.25">
			<a class="ms-currentRating"><img class="ms-rating_2" src="/_layouts/Images/Ratings.png" alt="Current average rating is 2 stars." /></a>
        <xsl:if test="@Ratings &gt;= 1.25 and @Ratings &lt; 1.75">
			<a class="ms-currentRating"><img class="ms-rating_1_5" src="/_layouts/Images/Ratings.png" alt="Current average rating is 1.5 stars." /></a>
        <xsl:if test="@Ratings &lt; 1.25">
			<a class="ms-currentRating"><img class="ms-rating_1" src="/_layouts/Images/Ratings.png" alt="Current average rating is 1 star." /></a>
        <xsl:if test="string-length(@DocumentIconImageUrl) != 0">
           <div class="image-area-left">
               <img class="image" src="{@DocumentIconImageUrl}" title="" />
        <a href="{$SafeLinkUrl}" title="{@LinkToolTip}">
          <xsl:if test="$ItemsHaveStreams = 'True'">
            <xsl:attribute name="onclick">
              <xsl:value-of select="@OnClickForWebRendering"/>
          <xsl:if test="$ItemsHaveStreams != 'True' and @OpenInNewWindow = 'True'">
            <xsl:attribute name="onclick">
              <xsl:value-of disable-output-escaping="yes" select="$OnClickTargetAttribute"/>
          <xsl:value-of select="$DisplayTitle"/> 
This first does a test to check which range the average rating falls into, and then outputs the necessary code to show the correct amount of stars. I’ve also include document title and icon. What you end up with is something like this:
Very nice!

SharePoint 2010 RTM

April 18, 2010

SharePoint 2010 RTM will be here in 9 days!

Volume licensing customers with Software assurance customers will get it first (me me me!) starting April 27th.

Lots of work to do now….

Read the Microsoft SharePoint team blog for all the info: You should also subscribe to this blog’s feed if you’re interested in SharePoint. It is a constant source of valuable information.

Thanks @nztechtweet, @davidpae and @marcelalberts for the heads up on this news.

iPhone contact sync – what a nightmare!

January 4, 2010

After having my iPhone for over a week I thought I had better migrate all my contacts over from my old mobile. I had been procrastinating as I thought I would have to do it manually.

Turns out doing it manually may have been faster.

First I realized that my crappy old phone actually had Bluetooth and so does the iPhone. This old Sanyo 6600 was able to pair with the iPhone but the iPhone was not capable of receiving the contacts. Turns out the only thing the iPhone Bluetooth is good for is connecting to headset/handfree/ headphone devices and sending/receiving files from other iPhones or iPod touches (using an app like Mover).

iTunes however had a contacts sync function with Microsoft Outlook so I sent all my contacts to my laptop using Bluetooth, they transferred over pretty quickly, in .vcf format. I then had to drag these all into Outlook and save them one by one which was a bit if a pain.

The real pain though, was trying to get iTunes to sync with Outlook.

I just could not get this to work. Contacts already in my iPhone were synced to Outlook with no problem, however it would not add any new contacts to the iPhone. Hours of troubleshooting and forum trawling later I gave up on Outlook. I exported all the contacts as a .csv file and imported them into Windows Mail. I then set iTunes to sync Windows contacts instead of Outlook contacts and voilà! It worked. What a nightmare though!

My first iPhone!

December 28, 2009

So my dear husband got me a shiny new 16GB iPhone 3Gs for Christmas/my birthday and I’ve barely put it down since 8am Christmas day.

You would think being a bit of a geek I would already have a fancy gadget like this but I don’t. While I love new technology and all, I am also a bit of a tight-arse hence even though I yearned for an iPhone for a long time, I didn’t want to fork out the $$ for it. Now I realise though, it is definitely worth the big bucks. It is just spectacular. It is fast, intuitive and everything else a smartphone should be. Now I can tweet, blog, Facebook and surf the net from (almost) anywhere.

I haven’t had a heap of time to try out many apps but here’s a couple that have already become favourites:

Flightcontrol: just guiding some planes onto a landing strip sounds kinda boring but this is one of the best games I’ve ever played! Warning: highly addictive.

Tweeite 2: I first installed twitterific since it was free and it was OK, but it didn’t really inspire me to tweet much. Tweetie 2 came highly recommended (via @mc_stacey) so I spent the $4 and installed it today. This is an absolutely fantastic app that is very intuitive and seems to be designed exactly around the way people use Twitter. Wins it has over twitterific are the ease of tracking @reply conversations back and forth, the translate feature, the ‘in reply to’ and ‘from inserttwittetappnamehere’ links, viewing tweets integrated with twitpic/yfrog/etc pics and the individual profile viewing is much better. The geotag feature looks quite cool and the ‘post to tweetie’ safari bookmarklet will no doubt come in handy.

TVNZ app: this app is nice because it’s free and is also very easy to use. In my opinion, it also gives more accurate NZ weather information than the Yahoo weather function that comes with the iPhone. This app gives you lots of news headlines which you can view by category and it also has a TV schedule (including TV3) and a podcasts area.

WordPress: I had initial problems setting this up (it kept telling me I had the wrong password but then it just started working) but despite this it seems to be a nice wee app that I am using to write this very post. You can manage posts, pages and comments with the easy to use interface. You can add pictures to your posts, however it doesn’t look like you can do other advanced editing like adding hyperlinks or bulleted lists. It will no doubt become very useful for short posts on the fly though. Now there is no reason to have such a long time in between blog entries!

Installing Office Web Apps in a Standalone SharePoint 2010 environment

November 27, 2009

I recently set up a new VM (on a Hyper-V host) with Windows Server 2008 R2 for the purpose of evaluating SharePoint Server 2010 beta. This is a single server, standalone environment – domain controller, SQL server 2008 and SharePoint Server 2010 all on one VM.

Here are the resources I read through (I obviously didn’t read one of them well enough, you’ll understand later) to get set for installing SP Server 2010 beta and Office Web Apps beta in this standalone environment. These references contain download links and product keys too should you need them. (Deploying Office Web Apps)

After installing all prerequisites for SharePoint 2010 (including SQL 2008 SP1, CU2 and CU3) I set out to install SharePoint 2010. Now, if you read through the TechNet resource on deploying Office Web Apps, you’ll see that there is a wee bit of Powershelly stuff you’ll need to do to activate and start the Office Web App services and to create the service apps and proxies. This needs to be done only if you run the SharePoint post-setup configuration wizard as part of your SharePoint 2010 installation. I was keen to avoid this, hence here are the steps I followed to get everything up and running:

  1. Ran prerequisite installer from SharePoint 2010 setup to ensure I hadn’t missed any prereqs
  2. Ran SharePoint Server 2010 OfficeServer.exe setup (using complete installation option to be able to use full blown SQL 2008)
  3. REMOVED TICK from “Run the SharePoint Products and Technologies Configuration Wizard now” box. (Do not run the config wizard at this time unless you want to manually active Office Web Apps using Powershell)
  4. Ran Office Web Apps WcServer.exe setup
  5. Once the setup is finished, the “Run the SharePoint Products and Technologies Configuration Wizard now” box should be ticked. Click close to start the wizard and run through
  6. Ran Farm configuration wizard from Central Administration

All done! Well, kind of. I happily went and created my first site collection, uploaded a Word document and tried to open it up to test Office Web Apps. Word Web App launched and appeared to be OK, but after several minutes of SharePoint “processing” my document I got an error that read: “Word Web App cannot open this document because the server is still processing the document. Please try again later.”

OK. So tried an Excel document – that opened fine. Unsurprisingly really because Excel has it’s own web services which have been around since MOSS 2007. Then tried a Powerpoint document and I got a different error, something along the lines of “network connection interrupted” which didn’t make any sense. At first I thought it might have been a resourcing issue, so I turned off a couple of VMs and allocated some more RAM to this one, same problem though.

So after SEVERAL hours of looking through event logs, Googling, looking in every dark corner of Central Administration, testing and retesting, I decided to re-read through the deployment instructions. In Jie Li’s article (3rd link in the above list), under step 11 we have the following note:

If you are trying to use Office Web Applications on DC (Office Web Application need to be installed seperately, like a language pack or an update. Please also note that Office Web Application cannot be installed on Windows 7), then the following commands need to be run to make the services work. Please note that in different languages, Service Application names could be localized. You can find them out by Get-SPServiceApplication, and then change the names in the script as necessary.

$e = Get-SPServiceApplication | where {$_.TypeName.Equals("Word Viewing Service Application")}
$e.WordServerIsSandboxed = $false

#(Please use the below script for PowerPointServiceApplication - You need to enter "Y" for the answer of each cmd)
Get-SPPowerPointServiceApplication | Set-SPPowerPointServiceApplication -EnableSandboxedViewing $false
Get-SPPowerPointServiceApplication | Set-SPPowerPointServiceApplication -EnableSandboxedEditing $false

In the server’s c:\windows\system32\inetsrv\config\applicationHost.config
Add the line below in the end of the dynamicTypes.
<add mimeType=”application/zip” enabled=”false” />


I had initially not seen this as I was using the TechNet article as my reference for installing Office Web Apps. So, because my server is also a domain controller I ran the Powershell commands and just like magic, Office Web Apps worked. Albeit a little slowly at first (possibly because I only have 3 GB RAM allocated to this server – don’t laugh) but after installing Silverlight it is nice and quick.

Issue resolved, I can now continue to play with SP2010.

Blowing shit up

October 9, 2009

So I’m staying up late (yes, past midnight on a Friday, what a rager!) to watch the Americans smash a rocket into the moon. I’ll expand on this post later. I expect this to be one of those things that is massively hyped up only to end up being a huge let down – still can’t help but watch it though.

UPDATE: Yes, it was a huge disappointment. People around the world had their eyes glued to NASA TV, anticipation building as mission control were counting down – “1 minute to centaur impact!” – hoping for at least some kind of visible plume. What we got was this:

Yeap, a bit fat lot of nothing.

So in light of this, below are my picks for the best explosions of all time.

Best TV explosion


The team on the Discovery Channel show Mythbusters relish in blowing stuff up, and they are damn good at it. In episode 117 they tested various methods that could supposedly lead to homemade diamonds. Obviously they all failed (otherwise we’d all be doing it!) so they resorted to using 5,000 pounds (2,300 kg) of explosives to see if an explosion of this magnitude would instantly convert carbon into nice shiny diamonds. It did work, albeit creating only “industrial grade” diamonds. Sorry to say guys, but even if 5000 pounds of explosives could create a top quality stone, it’s still going to be cheaper to buy her that huge diamond engagement ring from the jewellery store.

Watch the videos here: Mythbusters \”Homemade diamonds\” explosion

Best natural explosion

Tunguska event

Take the above explosion, multiply it by a million and you have the magnitude of the impact of the Tunguska event. There are several different hypotheses as to what exactly caused this event, but the most widely held belief is that it was caused by a large meteoroid or comet entering the Earth’s atmosphere above Siberia, and exploding, causing a massive, but indirect, impact. The result was an enormous shockwave that felled trees, killed animals and knocked people off their feet hundreds of miles away. In the few days after the impact, skies in Europe and Asia were said to be glowing – likely due to the formation of Noctilucent clouds high in the atmosphere, composed of ice particles left over from the explosion. According to this reference, “The Guinness Book of World Records (1966 edition) states that due to the rotation of the Earth, if the collision had occurred 4 hours 47 minutes later, it would have completely destroyed the city of St. Petersburg”. Close call.

Scorched and flattened trees as a result of the Tunguska event

Best movie explosion

Live Free or Die Hard

I am massively biased here because I am a HUGE fan of the Die Hard movies. I love the scene where John McClane uses a car to blow up a helicopter because, “I was out of bullets”. The creativity here, combined with the excellent one liner (although from memory I don’t think he actually uses this line in the movie, it is just in the trailer) and the fact that it’s John McClane means it wins my vote for best movie explosion.

Signing off with a lolcat….