28.05.2011 I have redone this solution to use a star-rating in stead of the simple “like” button. You find the new version here
01.11.2010 Redone the scripts and added support for rating individual items in a list – for example in “Dispform” in a blog:
The solution counts “Hits” and “Likes”.
Create a document library to hold your scripts
Or a folder on the root created in SharePoint Designer). In this example i have made a document library with a relative URL of “/test/English/Blog/Scripts” (a sub site named “test” with a sub site named “English” with a subsite named “Blog” and a document library named “Scripts”).
When you refer the scripts in the CEWP, ensure that you point to the correct location of your scripts.
The jQuery-library is found here. The CEWP code refers to jquery-1.4.2.min. If you download another version, be sure to update the script reference in the CEWP.
The sessvars.js is created by Thomas Frank and can be found here
Create a list with the name “HitCounter”, and add these fields:
- URL: Multiline plain text
- User: Person or Group
- ReferringURL: Multiline plain text
- Like: Single line of text
You have to give all users write access to the list “HitCounter”.
Add a CEWP where you want this counter to appear, and add this code:
- oncePerSession: True to allow one “hit-count” per unique item per browser session.
- isDispForm: If true, includes the ID of the item to allow individual counting of each item in a list.
Ask if something is unclear!