0

I have a Content Type "Picture". The contentmanager now wants to choose specific nodes of this ContentType and put them in a voteable list. The voting list should be auto generated if possible. Users can vote one this list. A user can only vote once and give exactly one vote. After voting, the user should see the ranking results and within his profile he should be able to see for what he voted.

Whats the best way to achieve this? I thought about using flags, but I would need to restrict a flag to a number of nodes and not per node. And with standard polling I don't see a way of generating the voting list.

0

You need to distinct those specific nodes using taxonomy or a custom field, like a boolean field, say, 0 means no vote and 1 means needs voting. Then use the the flag module to filter those nodes. like this

enter image description here


UPDATE :

The basic idea is, when user flags a content, you can set all of the 1s to 0 in this way no more content will be votable. To do so you need to use hook_flag_flag function. in this function use node_load to load the nodes of boolean value 1, set it to 0 then use node_save to save the node.

| improve this answer | |
  • I like the idea of setting a boolean field to distinct the votable noded but I don't quite understand the rest - it seems like I can still flag/vote any of those distinct nodes right? What I want is that I can only vote on one of those distinct nodes. – ash May 7 '15 at 9:13
  • From what I understood there is a content type, and it has many nodes and you need to make some of these nodes votable, right? so first add a boolean field and set the default to 0 and for votable nodes set it to 1. To flag only the nodes with boolean value of 1, on filter criteria, click on the add button, and then search for the name of that boolean field. add this field and set its value to 1. – M a m a D May 7 '15 at 12:21
  • Ah let me explain a little bit better: yes, I need to make some of those nodes votable so the boolean field works fine. But now, from this list of nodes, the user should only vote on one. So those nodes can be ranked, like: "chose your best picture -> list of node pictures -> user sets his one vote". Can I do this with flags? Because from my understanding you can flag each votable node and not only one of them. – ash May 7 '15 at 12:58
  • I updated the answer – M a m a D May 7 '15 at 13:24
  • thanks I'm trying it this way. One thing, isn't now the node only votable once for all users? And not once per user? – ash May 7 '15 at 15:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.