Customize rating icons for SharePoint 2010

2 May
In SharePoint 2010 the rating icons are default displayed as stars: 
 
Of course these can be changed: with SharePoint Designer, but better with a feature.
There are four images used to display the ratings:
  • 2 images for displaying rating:
    ratings.png

    ratingsrtl.png
  • 2 images for hovering/selecting rating (enlarged):
    ratingsempty.png
    ratingsnew.png

You can find these images in the 14 hive, images folder.
Make your custom icons (16×16), I prefer (the free) Paint.NET program. Just open the original icons, save them with another name and make your own of them.

How to change these images by SharePoint Designer

Open the site in SharePoint Designer.
Select Site Options in the ribbon:
 
 In the Tab parameters you can find the locations of the images by name value pairs. Here you can change the images to your own ones. Recycle application pool to see the changes.

How to change these images by a feature

Create an empty SharePoint 2010 project with Visual Studio 2010 and add a site collection scoped feature.
Add a SharePoint Images Mapped folder and add your images to this folder. Note: Visual Studio adds a subfolder with the name of your project to your and SharePoint’s images are not messed up, nice!

Add an event receiver to your feature to set the properties of the images.
Uncomment the FeatureActivated method and add code:
SPSite site = properties.Feature.Parent as SPSite;
SPWeb web = site.RootWeb;
//preserver original ones
web.AllProperties[“ratings_imagestripurl_original”] = web.AllProperties[“ratings_imagestripurl”];
web.AllProperties[“ratings_newratingiconurl_original”] = web.AllProperties[“ratings_newratingiconurl”];
web.AllProperties[“ratings_emptyiconurl_original”] = web.AllProperties[“ratings_emptyiconurl”];
//set new ones
web.AllProperties[“ratings_imagestripurl”] = “_layouts/images/ITIdea.CustomRatings/RatingsFC.png”;
web.AllProperties[“ratings_newratingiconurl”] = “_layouts/images/ITIdea.CustomRatings/RatingsNewFC.png”;
web.AllProperties[“ratings_emptyiconurl”] = “_layouts/images/ITIdea.CustomRatings/RatingsEmptyFC.png”;

web.Update();

Uncomment the FeatureDeactivating method and add code:
SPSite site = properties.Feature.Parent as SPSite;�
SPWeb web = site.RootWeb;�
web.AllProperties[“ratings_imagestripurl”] = web.AllProperties[“ratings_imagestripurl_original”];�
web.AllProperties[“ratings_newratingiconurl”] = web.AllProperties[“ratings_newratingiconurl_original”];
web.AllProperties[“ratings_emptyiconurl”] = web.AllProperties[“ratings_emptyiconurl_original”];
web.AllProperties.Remove(“ratings_imagestripurl_original”);
web.AllProperties.Remove(“ratings_newratingiconurl_original”);
web.AllProperties.Remove(“ratings_emptyiconurl_original”);

web.Update();

Deploy and activate the feature and recycle the application pool.
The new custom rating icons are visible and ready to use!
When you deployed the feature, check the Site Options in SharePoint Designer and you will see the original and newly added properties:


After deactivating the feature the original images are set again (and iisreset).

4 Replies to “Customize rating icons for SharePoint 2010

  1. I seriously do not think I would be able to keep up with maintaining a site like it! Fantastic piece of work and I absolutely would like to see you keep up with it for a long time.

  2. Thanks a good deal! I truly enjoyed reading this.Looking through these posts and the information you’ve provided I can appreciate that I still have a lot of things to learn. I will keep reading and keep re-visiting

  3. Substantially, the article is really the sweetest on this deserving topic. I agree with your conclusions and will thirstily look forward to your incoming updates. Saying thanks will not just be sufficient, for the phenomenal clarity in your writing. I will at once grab your rss feed to stay informed of any updates. Admirable work and much success in your business dealings!

  4. I recently came across your blog and have been reading along. I thought I would leave my first comment. I don’t know what to say except that I have enjoyed reading.

Comments are closed.