So after looking a lot, I finally realized what the problem is. This issue made me realize the solution #284292: Where's Views Argument Handling Code

The votingapi_cache table is inner joined to the node table. This means that the intersection of the nodes in the node table and the nodes in the votingapi_cache table are shown. What I really wanted instead was all of the possible nodes + the fields from the nodes which had been voted on. This is a left join instead.

So I created a very, very small module to do this, and I need feedback to make sure this will work as I expect it to.

In a module, I called it site_tweaks.module I put the following:

// $Id$

/**
 * @file
 * Makes minor tweaks in a few modules
 */

/**
 * Implementation of hook_views_query_alter().
 */
function site_tweaks_views_query_alter(&$view, &$query) {
  // note here: if you want to affect your views, you need to put your view names in there.
  if ($view->name === 'My_Resources' || $view->name === 'All_Resources') {
    $query->table_queue['votingapi_cache_node_percent_vote_average']['join']->type = 'left';
  }
} 

(include the php tags).

In another file called site_tweaks.info, I put the following:

; $Id$
name = Site Tweaks
description = Modify other modules in here.
package = Pedagogle
core = 6.x

I placed both of these inside a folder called site_tweaks in my modules folder. Enabled the module. Navigate to my view, and voila, all of my nodes of the appropriate type, including ones without any votes, are included.

If this is the right way to do this (and I tried every possible way I could think of using the Views UI), can we add this to the documentation for this module?

CommentFileSizeAuthor
#4 votingapi_322088.patch2.86 KBdrewish

Comments

moshe weitzman’s picture

Usually this table gets joined using a relationship. The INNER JOIN happens if you check the box 'require this relatonship'. At least thats my first thought upon reading this ...

dwees’s picture

Hrmm, well let me test it and confirm you are right. I do see I have checked "require this relationship".

Dave

drewish’s picture

subscribing. my problem seems similar but may be a separate issue. i've got require this relationship disabled but i need the sum of votes and for nodes without votes they aren't included.

drewish’s picture

Status: Active » Needs review
StatusFileSize
new2.86 KB

talked to merlin on irc and he suggested using COALESCE(field, 0) to force the NULL values to zero so the could be compared. i extended views_handler_filter_numeric to force the operators to coalesce. all-in-all a pretty simple fix that works like a charm.

drewish’s picture

[12:36pm] merlinofchaos:
drewish: Smaller patch: Override $query instead of the operators, and change $field directly
[12:36pm] drewish:
merlinofchaos: well the thing i like about this is that i still allows is null
[12:36pm] drewish:
if you want it
[12:36pm] drewish:
or is not null
[12:37pm] drewish:
merlinofchaos: would that work overriding query?
[12:37pm] merlinofchaos:
OH I see.
[12:37pm] merlinofchaos:
Hm.
[12:37pm] merlinofchaos:
You're right that would break those operators.
[12:37pm] merlinofchaos:
Carry on then!
computer_jin’s picture

Hi every one,
I am using votint module and its working fine at my local pc but when i use this from my server its working but voting images not showing to vote some onee....please tell me how can i solve this issue .....

eaton’s picture

Status: Needs review » Fixed

Just committed this to the dev branch. Thanks, drewish!

Status: Fixed » Closed (fixed)

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

Büke Beyond’s picture

Component: Documentation » Code
Priority: Normal » Critical
Status: Closed (fixed) » Needs work

"votingapi_views_handler_filter_value.inc" is missing on the Dev release.

lelizondo’s picture

I'm also getting this error

eaton’s picture

Status: Needs work » Fixed

This has been fixed for a while in the official supported releases.

Status: Fixed » Closed (fixed)

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

ezra-g’s picture

Version: 6.x-2.x-dev » 6.x-2.3
Status: Closed (fixed) » Reviewed & tested by the community

I'm having this issue in the 6.x-2.3 release but not the latest dev from the 6.x-2.x branch.

A grep of the 6.x-2.3 codebase shows that there is no COALESCE in the codebase, but it is present in the 6.x-2.x branch.

I filed #1417992: Release 6.x-2.4 to try to help with making a new 6.x-2.x release.

ezra-g’s picture

Status: Reviewed & tested by the community » Fixed

I should clarify that by "this behavior" I actually meant #346708: Views Sort by Voting API Results (descending) lists -1 before 0., which is resolved by the coalesce proposed in #4 in this issue.

Status: Fixed » Closed (fixed)

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