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.

CommentFileSizeAuthor
#8 advpoll-views2-integration.patch1.55 KBelstudio

Comments

ChrisKennedy’s picture

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.

SuperContraXTC’s picture

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

reubenavery’s picture

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

stinky’s picture

subscribe

stinky’s picture

subscribe

Vector-’s picture

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 ?):

function advpoll_votingapi_relationships() {
  $relationships[] = array(
    'description' => t('Advanced Poll'),
    'content_type' => 'advpoll',
    'base_table' => 'node',
    'content_id_column' => 'nid',
  );
  return $relationships;
}
ntg’s picture

Subscribing

elstudio’s picture

Status: Needs work » Needs review
StatusFileSize
new1.55 KB

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!

miro_dietiker’s picture

I'm happy to see this a little improved.

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

miro_dietiker’s picture

Status: Needs review » Fixed

committed to cvs after review.

thanks for your contribution.

Status: Fixed » Closed (fixed)

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