Гость
21 Нояб 2013 12:36

is ti possible to add stars to a rating template?

(the client want rating from 1 to 10)

in default rating template php fiel I see this code

<script  type="text/javascript" language="javascript">

  newRating<?php echo $key?> = felixRating.newRating( '<?php echo $vars->rating_ident; ?>_rateBox', <?php echo $vars->rating_active; ?> );

  newRating<?php echo $key;?>.setStars( { "14"  : '<?php echo JText::_("VOTE_AUWFL")?>',

                        "28"  : '<?php echo JText::_("VOTE_BAD")?>',

                        "42"  : '<?php echo JText::_("VOTE_NOTGOOD")?>',

                        "57"  : '<?php echo JText::_("VOTE_FAIR")?>',

                        "71"  : '<?php echo JText::_("VOTE_GOOD")?>',

                        "85"  : '<?php echo JText::_("VOTE_FERYGOOD")?>',

                        "100" : '<?php echo JText::_("VOTE_EXEL")?>' } );

  newRating<?php echo $key;?>.setCurrentStar( "<?php echo $vars->rating_current; ?>" );

  newRating<?php echo $key;?>.setIndex(<?php echo $vars->index?>);

  <?php if( $vars->callbackfunction ){ ?>

    newRating<?php echo $key;?>.setSedingFunction( <?php echo $vars->callbackfunction; ?>, '<?php echo $vars->prod_id; ?>' );

  <?php } ?>

</script>

do I just have to add values to this part

 "28"  : '<?php echo JText::_("VOTE_BAD")?>',

                        "42"  : '<?php echo JText::_("VOTE_NOTGOOD")?>',

                        "57"  : '<?php echo JText::_("VOTE_FAIR")?>',

                        "71"  : '<?php echo JText::_("VOTE_GOOD")?>',

                        "85"  : '<?php echo JText::_("VOTE_FERYGOOD")?>',

                        "100" : '<?php echo JText::_("VOTE_EXEL")?>' } );

or this won't work?

Последние изменения: 02 Март 2014


Sackgesicht VIP
Total posts: 1,636
21 Нояб 2013 16:55

I have not tried it, but it seems the number represents the percentage ..

I would suggest to add some lines and adjust the numbers to 10, 20, 30, 40, 50, 60, 70, 80, 90,100


pepperstreet VIP
Total posts: 3,837
21 Нояб 2013 20:44

Confirmed. Simply copy and rename XML and PHP file. Create/Copy an image folder as well! Rename it accordingly to your files! Foldername has to end with _img.

As mentioned before, simply add/edit the voting numbers in steps like: 10, 20, 30, ... etc.

Set Language constants to your liking. Cobalt language file includes not enough terms... so, you might add 3 more. You can add strings as overrides in J! core language manager.

See my working examples below. I tried the JED template:


Гость
22 Нояб 2013 02:21

thanks guys!

I was just too lazy to test this by myself, so lucky that you are not :-)


Гость
22 Нояб 2013 02:23

another question,

someone has some code sto suggest if I wanted to use numbers (1,2,3,4,5...) instead of stars

right now we have just one image (star) with active and unactive state

with numbers we would have many images (as many as the numbers) so I think

the code would be more complicated

just wondering if anyone has already tried thsi and can suggest the code

thank you


Sergey
Total posts: 13,748
24 Нояб 2013 00:28

template is css based. I am not sure but I remember there was something in css3 to add numbering. You can change style in template and instead of using image in background, insert numbering text.

http://www.hongkiat.com/blog/css-automatic-numbering/


pepperstreet VIP
Total posts: 3,837
24 Нояб 2013 05:08

use numbers (1,2,3,4,5...) instead of stars

Do you want to show each number? i.e. a voting of 4, shows 1-2-3-4

Or just the final rating number, only? i.e. 4

this might require a sort of "range-slider",

or a static muted display of all available numbers,

or hiding the actual rating numbers on hover/mouse-leave dynamically.


Гость
24 Нояб 2013 11:02

well, I was thinking about displaying all the numbers (1,2,3,4,...)

Работает на Cobalt