Star Rating Package - V1.0 RC1 Options
tim
Posted: Tuesday, November 20, 2007 10:33:43 AM

Rank: Addict

Joined: 2/19/2007
Posts: 738
Location: Belgium
Hi,

A while ago I made this package http://forum.umbraco.org/packages/star-rating-package--looking-for-some-testers

Now I am releasing the first version (rc1).

Source: http://testing.netcentric.be/TG.Umb.StarRating/xtraUmbracoStarRatingSourceRC1.zip
Package: http://testing.netcentric.be/TG.Umb.StarRating/Ajax_Star_Rating_1.0RC1.umb

Improvements that have been made:

- Added xsltExtension so it is possible to setup the rating in an xslt macro and control the ouputted html
- Supports dictionary items for the error and thank text.

Be sure that it is possible to write in the
/config/xsltExtensions.config
/config/restExtensions.config
Files otherwise you will have to do this manualy

XsltExtensions:
Code:

<?xml version="1.0" encoding="utf-8"?>
<XsltExtensions>
  <ext assembly="/bin/xtraUmbracoStarRating" type="xtraUmbracoStarRating.StarRating" alias="StarRating" />
</XsltExtensions>


restExtensions:
Code:

<?xml version="1.0" encoding="utf-8"?>
<RestExtensions>

  <ext assembly="/bin/xtraUmbracoStarRating" type="xtraUmbracoStarRating.StarRating" alias="StarRating">
    <permission method="update" allowAll="true" />
  </ext>
</RestExtensions>



And if you want to use the rater in your xslt macro:
Code:

<p>
Rate this post:
<span class='inline-rating'><ul class='star-rating small-star'> <li class='current-rating' style='width:{StarRating:getPercentage($node/@id)}%;' id='{$node/@id}'>&nbsp;</li><li><a href='javascript:updateStarRatingBar("{$node/@id}",1,0,"","")' class='one-star'>1</a></li><li><a href='javascript:updateStarRatingBar("{$node/@id}",2,0,"","")' class='two-stars'>2</a></li><li><a href='javascript:updateStarRatingBar("{$node/@id}",3,0,"","")' class='three-stars'>3</a></li><li><a href='javascript:updateStarRatingBar("{$node/@id}",4,0,"","")' class='four-stars'>4</a></li><li><a href='javascript:updateStarRatingBar("{$node/@id}",5,0,"","")' class='five-stars'>5</a></li></ul> </span>
</p>


Code:

<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library"
xmlns:StarRating="urn:StarRating"
exclude-result-prefixes="umbraco.library StarRating">






Umbraco tips and tricks: http://www.nibble.be - umbraco mvp 08/09 - certified level 1 & 2 professional
readingdancer
Posted: Tuesday, December 11, 2007 1:10:08 PM

Rank: Enthusiast

Joined: 9/27/2007
Posts: 24
Location: Reading, UK
Hi,

I have been testing your RC1 and have one issue and one suggestion :)

My issue is on a page that currently has no votes, with the mouse miles no where near the stars, i.e. not highlighting them, the first star and half of the second one are filled in, is the intended?

My suggestion / question is that if I was to use this in an FAQ area, ideally I would like to reset the stars if the "Answer" of the FAQ is updated, as hopefully if we update our FAQ's the answers will improve and hence the star rating will hopefully increase.

So I guess ideally this needs to link to the last updated date, or something like that?

Cheers,

Chris

Chris Houston - Business Dev Director for Ava / CTO for Clik Media Group / Umbraco Developer
tim
Posted: Wednesday, December 12, 2007 9:51:22 AM

Rank: Addict

Joined: 2/19/2007
Posts: 738
Location: Belgium
Hi,

Quote:

My issue is on a page that currently has no votes, with the mouse miles no where near the stars, i.e. not highlighting them, the first star and half of the second one are filled in, is the intended?


Check you css, there will be something that is interfering.

You faq question I don't really understand, but if you want to reset the rating for a certain document, you can do this with an actionhandler.


Greets,

Tim

Umbraco tips and tricks: http://www.nibble.be - umbraco mvp 08/09 - certified level 1 & 2 professional
Richard
Posted: Wednesday, February 06, 2008 7:11:28 PM
Rank: Enthusiast

Joined: 9/7/2007
Posts: 20
Location: UK

We have had a little play with this control and it looks to work OK. I have modified it slightly as it was not HTML validating; using the page ID as the unique ID creates some of the HTML elements with an ID that is just a number. So I modified the code to add "xsr" to the start of the ID value. So in the method BuildBar within xtraStarRatingBar.ascx.cs where

Code:

Output.Text += " <li class='current-rating' style='width:" + width + "%;' id='" + RatingBarUniqueId + "'>


this was changed to

Code:

Output.Text += " <li class='current-rating' style='width:" + width + "%;' id='xsr" + RatingBarUniqueId + "'>


and similar at the end of this method there are 2 lines changed to:

Code:

Output.Text += "<span id='xsr" + RatingBarUniqueId + "ratingtext' ...


Then we need to modify the javascript function updateStarRatingBar() within scripts/StarRatingBar.js:

Below the url definition add elementID:
Code:

        url = "/base/StarRating/update/"+id+"/"+value+".aspx";
        elementID = "xsr" + id;


then further down this function change the variable from ID to elementID that is passed to document.getElementById(), so it looks like:

Code:

  rateBar = document.getElementById(elementID);
  rateBar.style.width = value*20 +"%";
           
   createStarRatingCookie(id,value,100);
   if(textshown == 1)
   {
      rateText = document.getElementById(elementID +'ratingtext');
           
      rateText.innerHTML = "Thank you for your vote!";
   }
           
} else {
   rateText = document.getElementById(elementID +'ratingtext');
   rateText.innerHTML = "You can only place one vote!";
}
psterling@homax
Posted: Friday, February 08, 2008 11:17:13 PM

Rank: Fanatic

Joined: 10/30/2007
Posts: 215
Location: Bellingham
Tim -

Should I be able to "just" drop this (as a Macro) into a template and be able to have ratings?

When I add this Macro to an existing Template and run I get a JavaScript error:

updateStarRatingBar is not defined

which I take to mean that the .../scripts/StarRating.js file is not loaded. Indeed, I see no reference to this file in the output HTML.

I'll have a look at the source but please let me know if I'm heading in the wrong direction here.

Thanks,
-Paul

motusconnect.com :: level-2 certified :: MVP 2008/2009
bootnumlock
Posted: Friday, February 08, 2008 11:28:48 PM

Rank: Fanatic

Joined: 10/9/2006
Posts: 419
Paul...
you do have to add a reference to the JS and the CSS in your template file... in addition to adding the macro.

once you add those, you should be in business.

bootnumlock - aka bob baty-barr [http://www.baty-barr.com]
Level 1 Certified!
psterling@homax
Posted: Friday, February 08, 2008 11:35:46 PM

Rank: Fanatic

Joined: 10/30/2007
Posts: 215
Location: Bellingham
Bob -

I see...thanks.


Tim, Bob -

What are the tradeoffs for including/not including these references via the Macro/User Control itself? My approach would be to include these references to make usage a bit more "hands-off" but perhaps I'm overlooking something key.

-Paul

motusconnect.com :: level-2 certified :: MVP 2008/2009
chris
Posted: Thursday, June 05, 2008 2:26:27 PM
Rank: Devotee

Joined: 4/12/2007
Posts: 93
Location: Amsterdam
Hi all,
I implented the Rating script but it doesn't work like I would/hoped/expected....I use the macro which calles it:
Code:

<?UMBRACO_MACRO macroAlias="xtraStarRatingBar" RatingBarUniqueId="test56" IsInline="1" IsSmall="0" ShowOnly="0" ShowText="1" Text="stemmen!" ErrorText="foutje" ThankText="bedankt"></?UMBRACO_MACRO>


The problem I have that I have put the macro in a template but now the rating works over all pages and NOT a individual page.......I wanted to use the rating for video's but I think I'll have to do something with the RatingBarUniqueId-field because that's (I think) what causes my problem........Does anybody know how I can solve this?? (so that every page which uses the template gets his own rating)
thanks in advance
Chris
Dirk
Posted: Thursday, June 05, 2008 3:10:10 PM

Rank: Addict

Joined: 9/27/2007
Posts: 977
Location: Belgium
Change RatingBarUniqueId="test56" into RatingBarUniqueId="[#pageID]"

Regards,
/Dirk


level 1 certified - umbraco blog at netaddicts.be - working on an integrated forum4umbraco
chris
Posted: Thursday, June 05, 2008 3:44:50 PM
Rank: Devotee

Joined: 4/12/2007
Posts: 93
Location: Amsterdam
Great Dirk!!
Works perfectly now!! Thanks a lot.
Chris
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.