SPJS Hitcounter and star rating in DFFS

Forums Dynamic Forms for SharePoint SPJS Hitcounter and star rating in DFFS

Viewing 1 reply thread
  • Author
    Posts
    • #12050
      AdamP
      Participant

      Not a problem or question from me for a change – just a share of how we’ve implemented Alexander’s Hit Counter and Star Rating for SharePoint into a DFFS enabled list.

      We were asked by a user to provide some stats on views of list items. In the past I’ve implemented the hit counter exactly as per the blog post, but having a DFFS enabled list I thought we could save some effort, and avoid having to deal with loading jquery and SPJS Utility more than once.

      The hitcounter list is set up exactly as described in the blog post, and the HitCounterAndStarRatingForSharePoint.js file is stored in a convenient library.

      We then added the hitcounter code to the custom JS area in DFFS backend;

      $.ajax({
      url: “/sites/StyleLibrary/HitCounterAndStarRatingForSharePoint/HitCounterAndStarRatingForSharePoint.js”,
      dataType: “script”,
      cache: true,
      async: false,
      });
      var argObj = {counterListName:’HitCounter’,
      counterListBaseUrl:’/sites/’,
      countHits:true,
      hitCounterVisible:true,
      countOneHitPerUser:false,
      countOneHitPerUserPerDay:false,
      hitSuffix:[‘Hit’,’Hits’],
      isDispForm:true,
      activateRating:true,
      starImageSrc:[‘/sites/stylelibrary/HitCounterAndStarRatingForSharePoint/star_off.gif’,
      ‘/sites/stylelibrary/HitCounterAndStarRatingForSharePoint/star_on.gif’,
      ‘/sites/stylelibrary/HitCounterAndStarRatingForSharePoint/star_selected.gif’],
      starCount:5,
      starMouseoverArr:[‘Very poor’,’Poor’,’Good’,’Very good’,’Fantastic’],
      oneRatingPerUser:false,
      ratingCountSuffix:[‘Vote’,’Votes’],
      alreadyRatedMouseover:”You have already given this item {starCount} stars!”,
      debug:false};
      hitCounter(argObj);

      The code can probably be tidied up, but it logs hits nicely to the hitcounter list, and if you want the display of hits and ratings on the item you simply add

      <span id=”hitAndLike”></span>

      to the form in the location where you want it to appear.

    • #12098
      Alexander Bautz
      Keymaster

      Thank you for posting these instructions.

      Best regards,
      Alexander

Viewing 1 reply thread
  • You must be logged in to reply to this topic.