Greetings,

I am trying to setup a view that will return all of a users 'votes'. Ideally this would be a tab when viewing the user profile and would change with the specified user profile you are currently viewing.

I've got everything setup however, the part where I am faulting, which is the most critical part to getting this working correctly is the arguments.

Currently, it does not seem that the voting API provides any argument types to views. That being said, is there any way to achieve this?

I posted an issue in the views issue queue to see if it would be possible to use the argument handling code section of the views module to maybe create an argument that will filter results based on the user profile you are looking at (I have seen this done before in block form but not as a tab in the user profile).

Any help would be much appreciated!

Comments

peterdeitz’s picture

I'm looking for this feature as well.

seanr’s picture

Priority: Minor » Normal

Same problem here. This is a highly useful feature, marking up to normal.

sun’s picture

Title: Display all of users votes for others to see. » Add Views argument to filter by whether UID voted
Version: 5.x-1.5 » 5.x-1.6
Component: Miscellaneous » Code
Assigned: Unassigned » sun
Category: support » feature

#217815: Filter Votes by user on profile page has been marked as duplicate of this issue.

I'll try to come up with a patch shortly.

sun’s picture

Status: Active » Needs review
StatusFileSize
new2.11 KB

Here we go.

sun’s picture

StatusFileSize
new1.94 KB

New one, allows to enter a voting axis into the Views option field in favor of selecting between "has/has not voted on".

dww’s picture

Status: Needs review » Reviewed & tested by the community

This should definitely go in ASAP. I just found myself needing exactly this, the patch applies without offset, the code is clean and good, and the patch works as advertised.
Thanks!

sun’s picture

Status: Reviewed & tested by the community » Needs work

The problem with this patch is that VotingAPI/Views suddenly starts to use different table aliases for the votingapi_vote table when using percentage voting field (f.e. Fivestar) in the same view. This screws up the INNER JOIN this patch is using.

We tried to find a solution for this for several hours, but finally went with a custom implementation of this argument.

Our custom implementation for reference:

/**
 * VotingAPI argument handler limiting display to user votes given in
 * the passed argument UID and optional voting axis.
 */
function custom_votingapi_handler_arg_uid_voted($op, &$query, $argtype, $arg = '') {
  switch($op) {
    case 'filter':
      $uid = intval($arg);
      // Avoid _get_tables at all costs.
      $joininfo = array(
        'type' => 'inner',
        'left' => array('table' => 'node', 'field' => 'nid'),
        'right' => array('field' => 'content_id'),
        'extra' => array('content_type' => 'node', 'value_type' => 'percent'),
      );
      $query->add_table('votingapi_vote_vote_percent', FALSE, 1, $joininfo);
      $query->add_where("votingapi_vote_vote_percent.uid = $uid");
      if ($argtype['options']) {
        $query->add_where("votingapi_vote_vote_percent.tag = '%s'", $argtype['options']);
      }
      break;
  }
}
joachim’s picture

+1
This is an essential feature for votes.

themosttogain’s picture

I'm new to this but desperately desperately need this feature...where do i need to put the script that Sun has suggested? I've tired putting it into votingapi.views.inc but I can't see any new arguments or anything added in Views. Am I being dumb? I should mention i'm using Drupal 6.x not 5.x!

Thanks in advance to anyone who offers help!

eaton’s picture

Status: Needs work » Closed (won't fix)

Support for the 5.x branch of VotingAPI has ended with the release of Drupal 7 and the upcoming release of VotingAPI 7.x-2.4.

Anonymous’s picture

Issue summary: View changes