Hello everyone. I am not completely certain, maybe I am creating a duplicate entry here because I read something about incomplete Views support for Drupal 5.1 of VotingAPI - if so please do apologize if I do. But maybe some general explanations might be helpful to anybody really!
My problem is the following: I seem to have some problems understanding the Views integration of the VotingAPI and from the forum notes here and on other Drupal related sites, maybe some explanation might help.
Okay, this is my setup: Drupal 5.1 with VotingAPI, Views, CCK and Userreview. There is a CCK type called "ideas". Now users shall publish any good (or bad) idea they have on a particular topic. Using the Userreview module, I then want to have users vote and comment on these ideas.
This part works quite well and you can see that in listings, teasers, etc, the idea-nodes do get nice voting values.
Now comes the tricky part I cannot solve.
1) I want a page generated by views that lists ALL ideas in descending order according to the final voting result.
2) I want a top 10 ideas block that lists the top 10 voted ideas.
So first I set up a view that outputs all ideas in teaser form. This works nice, and I do see the votes to each node. Now I tell views to SORT the teaser list by voting result. My guess would have been to go the the Sort Criteria pane in views, the very last fieldset there, and so some sorting using the VotingAPI values offered here.
Now first of all, I do have a little trouble understanding what each individual entry REALLY does. I mean, I do have my guesses, but I am not certain. Maybe someone can go through the available list here and explain each option as some seem - at least to me - to be somewhat redundant. But I can be mistaken here...
Okay, in fact, I did it on trial and error and really tested out nearly any option - with no success. At some instances, the sort criteria set here would not change my teaser listing AT ALL, on other cases I ended up with an EMPTY teaser list.
The same applies when I try to configure a Top 10 block: I would opt for having a view to produce a block in table form, with Node Title and Voting Result in total accumulated points (e.g.) as fields (I say "voting results", this might not be the right wording probably which brings me back to my initial question of what each option REALLY spits out!), with a maximum of 10 items and no read more link, and have a sorting in the sort criteria from high to low on it. The block might look like this (with in total just three sample ideas):
Item Title Total Points
go swimming 309
have dinner 269
do homework 22
So again I took my guess and omitted final sorting but started to set up the block as that. In some cases, I did get nothing at all, in one case I got a value but this seemed hardly the value I am after. Now trying to sort definitively did not work at all again...
In summary:
- some explanation on the individual VotingAPI-items showing up in Views module would be very helpful.
- am I wrong or is this really not working (yet)
- is there another solution to at least get a top 10 block e.g. by some custom coding and how would I go about that?
Thanks a million,
Steve
Comments
Comment #1
gateone commentedHm, noone really seems to have any clue on this, which is sad. And (taking cries for help like this one into account which tells me: I am not alone! - I wonder what Voting API really is worth for?!
I mean, nice that it exists but if there doesn't seem to be a way to actually display results and all the Views integration in 5.1 isn't working at all, what's the point in the VotingAPI module then anyway.
Since it is an "API", maybe someone can point out how to at least write up some custom PHP block code to have VotingAPI at least spit out some sort of feedback from the polled votes it received on items voted upon.
Hope at least someone can help... :-(
Steve
Comment #2
coreb commentedI doubt this will be of much use, but I did want to respond. Back in February, I made a (released, but not publicized) module for the 4.7.x version that created a ballot in which the something could be nominated for multiple categories. This was voting on blogs, but my results page does something similar to what you want. It's a convoluted example, but maybe my clarifications below the code will help.
Every blog that could be nominated for something was in a CCK node, and every blog competing for an "award" was a taxonomy term. If you ignore all the themeing cruft, it's just going through each taxonomy term and displaying the votes that have already been calculated. BLOGAWARDS_CONTENT_TYPE was taxonomy, so the results were stored for each taxonomy term ($tid).
Although the page I linked to won't do it (it's now just a page node), the function was written so that you could minimize that to a lower number, instead of displaying all the results. So if the results page is at example.com/results, example.com/results/10 would give you the top 10 for each category.
Hope that helps.
If you really want to see the full module, I can post the URL, but I'm really not proud of it since it's my first (and only) Drupal module. It doesn't use any themeing or caching, which took down the database server multiple times an hour. It's also hardcoded for our setup.
Comment #3
coreb commentedI forgot to mention how I got the results out.
I didn't like the way votingapi_get_voting_results() worked, so I used my own version. Looking back on it, I probably should have used hook_alter_sql hook to edit the SQL, and return an array from the DB object.
Comment #4
gerd riesselmann commentedSee http://drupal.org/node/148357 for how I do it
Comment #5
eaton commentedViews integration in VotingAPI 5.x is fundamentally broken -- it works for a small number of cases but more complex cases like this are not supported, and this isn't being developed further. Views support was rewriten in the 2.x branch to fix these issues. If anyone wants to take a stab at rewriting the Views integration for D5, they're welcome to, but it's not on my radar at present.