Download & Extend

Views Relationship / VotingAPI integration seems incorrect due to content_type

Project:Advanced Poll
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

Vote's are being stored as content_type "advpoll".

The VotingAPI only has a relationship for "node" and "comment" types. This means when you define the Votes relationship, it tried to join in the votingapi_vote table using content_type="node". This causes no results (as the type is advpoll).

Solutions... I guess...
1) Change AdvPoll to store votes as "node"....
2) Add some Views integration to teach AdvPoll how to relate its votes to a poll node.

Comments

#1

Hmm I haven't used the views integration code - just committed the patch for another developer that requested it. I'm not sure what the best way to fix this would be - changing the content type from advpoll to node seems like a big pain to fix everywhere, although maybe it's easiest than #2.

#2

I am also trying to relate Views relationship with Advance Poll but I can not do it.

#3

The question I would pose is why does advpoll need a content type other than 'node'? Are advpolls to be considered differently than nodes?

#4

subscribe

#5

subscribe

#6

EDIT: Well... I initially had a big long post here about hacking this to work... but really I was just having some issues with Views caching... hehe, fun!

Anyhow, views integration with a current version of VotingAPI was quite easy, though there's a bit to know...

Using hook_votingapi_relationships() gets the content_type issue fixed - by adding a copy of the relationships 'Node: Vote results' and 'Node: Votes' for use with Advanced Poll data (with a minimal description denoting such), but VotingAPI's relationships don't know about the values AdvPoll puts in the 'function' field through this implementation...

Luckilly you can select Other and use the 'option-#', 'total_votes' (etc, didn't look farther) that AdvPoll saves

The hook_votingapi_relationships (add to advpoll.module ?):

<?php
function advpoll_votingapi_relationships() {
 
$relationships[] = array(
   
'description' => t('Advanced Poll'),
   
'content_type' => 'advpoll',
   
'base_table' => 'node',
   
'content_id_column' => 'nid',
  );
  return
$relationships;
}
?>

#7

Subscribing

#8

Status:needs work» needs review

I've attached a patch that improves views2 integration for advpoll.

It does two things:

* Provides Vector's code so that views2 recognizes advpoll data
* Allows printing of choice label for advpoll binary nodes. I've done this by adding a formatter for a vote's value. (Ideally, it should be on the tag, not the value -- but votingapi doesn't implement hooks for tags right now.)

Please review!

AttachmentSize
advpoll-views2-integration.patch 1.55 KB

#9

I'm happy to see this a little improved.

Please review and i'll commit any progress on this.

#10

Status:needs review» fixed

committed to cvs after review.

thanks for your contribution.

#11

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

nobody click here