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?
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | votingapi_322088.patch | 2.86 KB | drewish |
Comments
Comment #1
moshe weitzman commentedUsually 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 ...
Comment #2
dwees commentedHrmm, well let me test it and confirm you are right. I do see I have checked "require this relationship".
Dave
Comment #3
drewish commentedsubscribing. 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.
Comment #4
drewish commentedtalked 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.
Comment #5
drewish commentedComment #6
computer_jin commentedHi 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 .....
Comment #7
eaton commentedJust committed this to the dev branch. Thanks, drewish!
Comment #9
Büke Beyond commented"votingapi_views_handler_filter_value.inc" is missing on the Dev release.
Comment #10
lelizondo commentedI'm also getting this error
Comment #11
eaton commentedThis has been fixed for a while in the official supported releases.
Comment #13
ezra-g commentedI'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.
Comment #14
ezra-g commentedI 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.