I would like to be able to filter polls in views by status, if it is closed or open.

Comments

floretan’s picture

Status: Active » Needs review
StatusFileSize
new5.86 KB

Here's a patch that adds views integration to the advpoll module. The code is mostly based on the views integration of the VotingAPI, but modified to pick up the data from the advpoll module (which differs slightly from the VotingAPI data, even though it's stored in the same table).

ChrisKennedy’s picture

Hey, well done :) To what extent have you tested this with different advpoll settings?

floretan’s picture

I only did the "option" value type used by binary polls.

ChrisKennedy’s picture

Version: 5.x-1.x-dev » 6.x-1.x-dev
Status: Needs review » Patch (to be ported)

Okay I went though this, added a little support for {advpoll} fields so you can filters polls by open/closed status, and committed.

http://drupal.org/cvs?commit=166835

browlands’s picture

Any plans to make a version 6 commit for rudementary views integration?

Apollo610’s picture

Subscribing - would like to see this in views for D6 as well!

vacilando’s picture

Subscribing. I need this esp. to be able to show various polls in blocks depending on arguments.

Anonymous’s picture

Is there any ability to create additional field/sort criteria/filter in Views for this module? It would be great to have "Total votes" field in Views for node with pollfield applied. Or sort to display 10 most voted polls, for example...

travis.hill’s picture

+1 for "total votes"

markus_petrux’s picture

Status: Patch (to be ported) » Needs review

Here's a start to integrate Adv.Poll in Views for Drupal 6:

1) Edit advpoll.module and add the following:

/**
 * Implementation of hook_views_api().
 */
function advpoll_views_api() {
  return array(
    'api' => 2,
    'path' => drupal_get_path('module', 'advpoll') .'/views',
  );
}

2) Create the 'views' subdirectory in the advpoll folder and upload the attached file as advpoll.views.inc

This file creates a Views group for Advanced Polls fields, filters and so on. It implements the poll active state, the question and start/end dates. It's just a start and maybe other wish to add more stuff. This has been enough for us.

markus_petrux’s picture

StatusFileSize
new2.21 KB

The file was not attached in the previous post for some reason. Sorry.

miro_dietiker’s picture

Assigned: Unassigned » miro_dietiker
Status: Needs review » Reviewed & tested by the community

Great progress, markus.
Looks good to me and dereine also confirmed that this should be fine.
Assigning to me to commit it soon.

miro_dietiker’s picture

Status: Reviewed & tested by the community » Fixed

Tested and committed to cvs. Thank you markus.

miro_dietiker’s picture

Assigned: miro_dietiker » Unassigned

unassigning

yngens’s picture

subscribe

Vector-’s picture

I think this is related ... I just needed the Views Relationships to get the correct joins to apply some custom filters

VotingAPI provides a hook for custom content_types for its relationships - though is output leaves something to be desired...

None the less, I've found it quite handy for what I'm doing, and I'd imagine it could be extended to quite a number of other uses

I haven't bothered to put up a patch, since my solution produces a somewhat un-intuitive experience:
Since it's still on node basetable, VotingAPI only changes the description text of the relationship, and otherwise it appears a duplicate of the normal 'Node: Vote Results' ...

This already has its own issue: #553350: Views Relationship / VotingAPI integration seems incorrect due to content_type
But as I noted there... AdvPoll doesn't store data the way VotingAPI expects it, so for a more intuitive experience, custom relationship handlers would be needed

Status: Fixed » Closed (fixed)

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