Posted by crea on August 31, 2009 at 7:11am
| Project: | Vote Up/Down |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
There's very nice thing I want to implement: amazon-style simple rating system on reviews - 1 question "was this review useful ?" and 2 answers - Yes + No. I wonder is it possible to implement such type of voting using this module ?
My thoughts on this: "vote up" would be "Yes" and "vote down" would be "No", then I would need to implement separate voting widget that outputs this question and 2 answers. Then there will be 2 issues:
1) with hiding voting controls and outputting in plce of them something like "Thank you for voting"
2) with counting votes, since this type of voting requires to count ratio as (Number of "yes" votes / Total number of votes).
Comments
#1
The new vote up down module should have the ability to change widget easier than the 1.x branch. I move this issue to that, you could have more luck.
#2
yes i am very interested in this feature. I want to have yes/no voting for a certain node type. The widget stuff is easy as long as you have a little experience with theming/css. I am getting stuck with calculating the total number of yes (up) votes and total number of no (down) votes.
There is an issue (http://drupal.org/node/413980) that gives a possible solution, but it is for the 1.x branch. Plus after I implemented this solution I had some problems with the display of the results and clearing the old results. Not to mention the anonymous voting for the 2.x branch is awesome!
There has to be a fairly easy patch (for someone who knows module development) where you can count the number of yes (up) votes and the number of no (down) votes. I'll play with the files and see if I can come up with anything, but to be honest I don't really know what I am doing.
The next step would be integrating these yes/no results into a view.
#3
Well i'm sure you don't need any patch for getting number of votes. Getting number of votes should be easy with standard VotingAPI functions, i.e. votingapi_select_results().
If you managed to get this voting widget to work can you please post your steps ?
#4
well I am having a extremely hard time figuring this out. I'd post my code but just really have no idea what im doing.
#5
@davedg629: Your request is pretty simple with the 2.x branch.
The only Issue I see in your way is that there is no way to put the widget after the content of the node...at least none I see. The weight of -10 is hard coded in the node_api implementation. In the 1.x branch you were able to disable the widget entirely for a node (ie: "Do not show in full view or teaser"), then call the widget ( what you'd use now is vud_votes_proxy() ). Best as I can tell, a little module hack of changing the weight to
2from-10is the only way to accomplish what you're trying to do.Perhaps another option is to not enable vud for your node-type on the vud configuration page, then call the widget manually using vud_votes_proxy(). I think this would work.
Everything else you need to do can be accomplished easily using the templating system. I haven't refined my CSS, but I've attached it here for you to get you started:
.vud-widget-updown {
padding: 5px 10px;
-moz-border-radius: 10px;
-webkit-border-radius: 10px
-opera-border-radius:10px;
-khtml-border-radius:10px;
border-radius: 10px;
border: 1px #ddd solid;
background: #efefef;
}
.vud-widget-updown a:hover {
text-decoration: none;
}
.vud-widget-updown .up-inactive,
.vud-widget-updown .down-inactive {
font-weight: bold;
text-align: center;
color: #000;
font-weight:bold;
}
.vud-widget-updown .up-inactive:hover{
color: green;
}
.vud-widget-updown .down-inactive:hover{
color: red;
}
.vud-widget-updown .up-inactive,
.vud-widget-updown .up-active {
padding: 0 1em;
}
.vud-widget-updown .down-inactive,
.vud-widget-updown .down-active {
padding: 0 1em;
}
.vud-widget-updown .up-active,
.vud-widget-updown .down-active {
font-weight: bold;
text-align: center;
cursor: default;
color: #cccccc;
}
and the twidget.tpl.php file, something like this:
<?php
$query = "Did you find this $node_type helpful?";
<span class="vote_query"><?php echo $query; ?></span>
<a href="<?php print $link_up; ?>"><span class="<?php print $class_up; ?>" id="updown-up-<?php print $type; ?>-<?php print $cid; ?>" title="Vote up!">Yes</span></a>
<a href="<?php print $link_down; ?>"><span class="<?php print $class_down; ?>" id="updown-down-<?php print $type; ?>-<?php print $cid; ?>" title="Vote down!">No</span></a>
</div>
#6
Thanks, vood002.
I will try this later. If there are problems with weights, I may publish a patch to the vud module.
#7
subscribing.. wondering if this was implemented yet in the dev version? I was interested in using this module for that exact feature, on rating comments as useful or not ...
#8
I just implemented a "was this review helpful" solution by duplicating the "updown" widget theme included in the 2.x branch and adding the text to the widget in widget.tpl.php. Just enabled vote up/down and vote up/down node and configure vote up/down to displaye on your node type. Then copy the theme directory and modify the widget code and select that widget theme in vote up/down options. Super simple, though a widget label feature would be nice out of the box. :)
#9
I've created a new feature request to be able to change the weight of the widget at http://drupal.org/node/736338.
In my code I hardcoded the node_api weight to 10, so it shows up after the node body. I've attached the widget I built, a very simple modification upon 'plain'. It works great for me, you may want to change it a little bit (especially the widget.tpl.php).
#10
You can change the weight like I mentioned in #736338: Ability to change weight of widget in order to display it after the node body.
About changing the way the widget is shown, you can implement your own widget, please take a look at WIDGETAPI.txt.
About solving the issue mentioned by crea at the start of this issue, maybe is a straight forward solution to use flag module. (aka we love diversity ;-))
#11
Flag can't be used for this: it's a binary system (vote/no vote) , while "was this useful ?" is a ternary system (yes/no/no vote).
#12
flag empty = no vote?
#13
Yes, empty flag = lack of vote. There is no "No" option.
#14
Ok, sorry for misunderstood the issue, after re-reading..
I can only answer the second question: it's possible when #745058: add a hook to preprocess variables passed to widget.tpl.php is done, because you'll have the opportunity to change variables, including the score.
#15
trying to answer the 1st question:
I think it would be possible to do that also when the issue mentioned is done, so you can place a special class to identify non-voted widgets and also adding some js to handle those classes
#16
Automatically closed -- issue fixed for 2 weeks with no activity.
#17
I implemented a was this helpful type voting on my site by creating an additional widget - see attached patch.
#18
Sorry, Ignore #17 - patch had absolute path
I implemented a was this helpful type voting on my site by creating an additional widget - see attached patch.
#19
Thanks useful/helpful widget in #18.
It seems to be missing the alter template variables function. Attached patch fixes this and adds in the reset link, if available.
#20
@expandonline, @John Money: Thanks for the patches.
This is a support request issue against 6.x-2.x, so patches here are not really expected. alter template variables widget callback was added only on 6.x-3.x branch.
Anyway, now 6.x-3.x is the stable branch, and 7.x-1.x the development branch, so all new features(like a new widget) should be added there. So if there is interest about this, please open a new feature request issue on 7.x-1.x version.
Closing this issue again.