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
The sourcecode for the file “HitCounterForSharePoint.js” is 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:
<script type="text/javascript" src="/test/English/Blog/Scripts/jquery-1.4.2.min.js"></script> <script type="text/javascript" src="/test/English/Blog/Scripts/sessvars.js"></script> <script type="text/javascript" src="/test/English/Blog/Scripts/HitCounterForSharePoint.js"></script> <script type="text/javascript"> hitCounter(true,true); </script>
Parameters:
- 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!
Regards
Alexander
March 29, 2012 at 3:02 pm |
Hi Alexander, just wanted to let you know I just implemented the Hit and Like Counter on our intranet (SP2007 MOSS) and it works great. Think I’m becoming some kind of “Alexander groupie”, since I have used a couple more of your script to enhance our article pages
. Thanks for all the great work!
Claudia
(ps If you like a screenshot of our article pages with your scripts, just let me know)