Closed (fixed)
Project:
jRating
Version:
5.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Reporter:
Created:
29 Oct 2007 at 22:48 UTC
Updated:
27 Nov 2007 at 11:04 UTC
I thought this might be quite useful as a vote mostly only needs to be cast once (site dependant, so maybe add at least as an option).
Only display the "rate this" element until a vote is cast, then hide using js (whilst continuing to display the average).
One-time voting has been discussed before but this was focused on locking the vote as opposed to only showing the voting mechanism when a vote has not been cast.
Same idea, different approach.
Comments
Comment #1
hickory commentedYou should be able to use javascript in theme_jrating_postsubmit to do this, but first I need to add a unique id to the rating div so it can be hidden.
Comment #2
bobdalob commentedI'd like to learn more about this. Can someone help out, particularly in this context, or point me to a useful resource on the subject?
Comment #3
hickory commentedI'll post here with some instructions once the unique id is in place.
Comment #4
hickory commentedThe rating widget has a unique id now, so:
Add a jrating_postsubmit function to a javascript file included by one of your custom modules or a theme:
You'll need the latest CVS version of jRating for this to work.
Comment #5
bobdalob commentedGreat. I'm going to try that out at the weekend.
Comment #6
bobdalob commentedHaving just tried the new version, I like the addition of options for "Allow users to change their ratings" & "Allow users to rate their own nodes". I think patches were available for both but great to see incorporated into the module options. The first of those may be enough for people looking at this thread.
On the subject of hiding the voting interface once voted:
I get the following error:
Comment #7
hickory commentedThat's a javascript function not a PHP function - where are you adding it?
Comment #8
bobdalob commentedAs suggested, I tried placing the jrating_postsubmit function into a javascript file included by a custom module - this did not hide the active part of the voting interface. I tried a few custom modules, that would be loaded with a node view, and their respective javascript files.
Once that was getting me nowhere, and it was already late, I was tired, I then placed it in a theme file which "happened to be php" and rightfully got my error!
Sorry, this is probably frustrating for you, "having to spell it out", however these are my limits - elsewhere I help where I can but I need help myself also - sometimes with what might seem to be the obvious. I'd really like to have some time to learn javascript and PHP (proper-like)! Thanks.
Comment #9
hickory commentedI think maybe I misunderstood your original intention: this javascript function will be called after a vote has been submitted, and will then hide the voting widget (but will show it again if the page is reloaded - as you mentioned, the 'allow users to change their ratings' preference will make it hidden permanently.)
If you put something like
alert('hello');within the function you'll be able to see whether it's actually being called once a vote has been submitted.Comment #10
bobdalob commentedI did in fact mean that (if already voted, page reload does not show widget) so when testing I was looking for something that wasn't meant to happen!
As you can see my understanding is limited. It was my thinking that, if the option to vote once only is used, then the voting widget should not re-appear on page reload, or perhaps should become inactive after a couple of seconds (freeze display the user's chosen rating). Nevertheless, the addition of the two mentioned config options, in the current development version, are certainly good enough for me.
Thanks again.
[Closed/fixed/patch? I don't know which this should be!]
Comment #11
hickory commentedClosed :-)