Keyword

Update item numeric rating

  • jozsefke
  • jozsefke's Avatar Topic Author
  • Offline
  • Junior Member
More
8 years 8 months ago - 8 years 8 months ago #146823 by jozsefke
Update item numeric rating was created by jozsefke
I have modified the views for categoryItem, Item, and genericItem to represent the rating of an article not only with stars, but also with a numeric rating next to them. The code for it looks like this:
<?php
$numericRating = round(($this->item->votingPercentage / 2), 0);
$numericRating = round(($numericRating / 10), 1);
echo $numericRating;
?>

You can see it in action here: www.szellms.hu/keprejtvenyek/1-kiskunfelegyhaza

It works great, it displays the item's rating correctly. However, when someone rates it, and the rating for example was 0, it doesn't update immediately after rating, only on page refresh. However, the text saying "0 votes" immediately updates to "1 vote" and the number of yellow stars also gets updated without refreshing the page. How can I make the numeric rating update too? So it would immediately display the new current rating without having to refresh the page.
Last edit: 8 years 8 months ago by jozsefke.

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 8 months ago #146838 by Krikor Boghossian
Replied by Krikor Boghossian on topic Update item numeric rating
Hello,

You need to update the rating script (AJAX) as well. The script is located in the k2.js file. You should unset that script and load your own version.
$K2.ajax({
			url: K2SitePath+"index.php?option=com_k2&view=item&task=vote&format=raw&user_rating=" + rating + "&itemID=" + itemID,
			...

You need to update the custom HTML part when the AJAX call is successful.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • jozsefke
  • jozsefke's Avatar Topic Author
  • Offline
  • Junior Member
More
8 years 8 months ago #146983 by jozsefke
Replied by jozsefke on topic Update item numeric rating
Thank you very much for your answer, Krikor! Could you please help me with modifying the script? How can I update the custom HTML part?

Please Log in or Create an account to join the conversation.

  • jozsefke
  • jozsefke's Avatar Topic Author
  • Offline
  • Junior Member
More
8 years 8 months ago #147097 by jozsefke
Replied by jozsefke on topic Update item numeric rating
Do you have any update about this topic?

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 7 months ago #147386 by Krikor Boghossian
Replied by Krikor Boghossian on topic Update item numeric rating
Sorry about the late reply,

you need to insert an div or span element with a unique id.
Then you can check the item's json feed (by applying the ?format=json ) and write the voting total in this element using the html() or text() jquery function.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • jozsefke
  • jozsefke's Avatar Topic Author
  • Offline
  • Junior Member
More
8 years 7 months ago #147398 by jozsefke
Replied by jozsefke on topic Update item numeric rating
Thank you for your kind support! I have the span inserted, and I can give a unique id to it. However, I am not really good at javascript, could you please tell me what do I have to write and into which file? I'm really sorry.

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 7 months ago #147864 by Krikor Boghossian
Replied by Krikor Boghossian on topic Update item numeric rating
Sorry for the late reply but this more of a custom implementation.
I can provide instructions and guidlines, debug code and help you but I cannot write scripts or implement extra functionality

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum