Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have been trying to create views with voting results but without result. No matter what relationship I add I cannot retrieve any actual data.
I have found many issues on the subject. I don't know if the View integration worked for 6.x version but it does not work with the 7.x. Almost all issues report that advance poll saves the votes in a way not recognized by the voting api.
Reference:
#1517110: Views cannot retrieve poll results
#553350: Views Relationship / VotingAPI integration seems incorrect due to content_type
Comment | File | Size | Author |
---|---|---|---|
#14 | advpoll-views-integration-1540674-14.patch | 673 bytes | joseph.olstad |
| |||
#10 | advpoll-views-integration-1540674-10.patch | 673 bytes | Anonymous (not verified) |
#8 | advanced_poll-views_integration-1540674-8.patch | 1.65 KB | drclaw |
#5 | AdvPoll Views.txt | 7.28 KB | perisdr |
#5 | VotingAPI table.png | 23.55 KB | perisdr |
Comments
Comment #1
perisdr CreditAttribution: perisdr commentedAfter playing around a lot I found a workaround for making advpoll work with views. I added some code in voting api to achieve this, so hopefully this can be implemented with a hook. Here 's how I created a table with the time my users voted along with their ip address.
Add this code in sites\all\modules\votingapi\views\votingapi.views.inc
If you know a better workaround please share.
Comment #2
Michele Wickham CreditAttribution: Michele Wickham commentedI'll go ahead and mark this as a feature request and see what I can come up with over the week. It should be pretty simple to implement your solution.
Comment #3
perisdr CreditAttribution: perisdr commentedIt may be pretty simple but not sure if it is correct. The problem for sure is that Voting API looks for votes with entity_type either saved as "node" or "comment". Advanced Poll saves the votes with entity_type "advpoll". In the previous issues the developer states two ways to resolve this. Tried to follow his way of thinking but not sure if my way has taken in mind all the possible scenarios (e.g in my way you cannot add data filters like points,percent,normal) Don't know if those were working in the 6.x version though.
Comment #4
Michele Wickham CreditAttribution: Michele Wickham commentedCould you check the latest version of the 7.x-3.x build and see if the way I integrated hook_views_data_alter correctly added your desired fix? If I'm not mistaken, you may need to do a full cache clear to get the view api call to kick in.
If this doesn't work, is it possible for you to export the view and send me a copy of it so that I can see how you're trying to build it?
Thanks!
Comment #5
perisdr CreditAttribution: perisdr commentedCouldn't make it work.
I only have one advpoll node.
Created a view with relationship "Content: Votes (Votes cast by users on nodes.)".
Added fields
I can see the query to the database is not correct.
So the hook to add another enity type 'advpoll' didn't work. Same problem for the "Content: Vote results (Aggregate results of votes cast on nodes.)" relationship. Only in this relationship the query is done to the votinapi_cache table and the entity type is still set to 'node' instead of 'advpoll'.
I am attaching the export of the view. Don't know if you can find something useful there to help you fix the problem.
Comment #6
Michele Wickham CreditAttribution: Michele Wickham commentedThanks - I'll get on this over the weekend - sorry for the delay.
Comment #7
catya CreditAttribution: catya commentedDid this fix get added? I'm not seeing it.
Comment #8
drclaw CreditAttribution: drclaw commentedThe problem, I'm finding with the fix that was added in http://drupal.org/node/1540674#comment-5896192 is that it overrides the default relationships provided by the voting api entirely. It makes it impossible to relate votes back to the node table. I'm not sure what the correct solution is, but I've attached a patch as a first attempt. I haven't had the chance to test it fully yet, however. I only noticed this issue because I needed the old votingapi relationships back. If someone could test it that would be great.
Thanks!
Comment #9
skylord CreditAttribution: skylord commentedCurrent code in advpoll.views.inc has no sense - this file can be deleted at all... Try this patch (basically the same as in #553350: Views Relationship / VotingAPI integration seems incorrect due to content_type but withour formatter - choices labels can be gathered with i.e. "Views PHP" from the same query without additional ones) - with it advpoll integrates with views like a charm for me:
Comment #10
Anonymous (not verified) CreditAttribution: Anonymous commentedMade a patch file so we can download it more easily in our projects .make file.
Comment #11
Anonymous (not verified) CreditAttribution: Anonymous commentedStatus update.
Comment #12
lukusHey - I've hit this issue. Wondering if others in the thread ever came to a satisfactory conclusion.
Thanks
L
Comment #13
adamazou CreditAttribution: adamazou commentedThanks Perisd, solution #1 worked for me. I tried everything from patching to using Voting Rules and etc..
FYI: I'm using
Drupal 7.32
Advanced Poll : 7.x-3.x-dev
Views : 7.x-3.8
Voting API : 7.x-2.12
Comment #14
joseph.olstadpatch 10 needed a reroll
Comment #15
Road Kill CreditAttribution: Road Kill commentedHas anybody been able to produce any poll results in views? I just don't see the Content: Votes relationship with advanced poll.
Comment #16
mikhailkrainiuk CreditAttribution: mikhailkrainiuk as a volunteer and at DrupalJedi commentedComment #18
mikhailkrainiuk CreditAttribution: mikhailkrainiuk as a volunteer and at DrupalJedi commentedOk. The patch committed.