| Project: | Views Crosstab |
| Version: | 6.x-1.0-alpha1 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
| Issue tags: | crosstab, Organic Groups, views, workflow |
Issue Summary
Hi.
Very interesting module. Though it does not work properly in my install : I tested it on two different Drupal installs and it shows the "Invalid argument supplied for foreach() in views_crosstab_table.inc on line 82." message. Not when viewing but just after validating the crosstab settings. In my own view but in the default view as well.
And if the operation on the columns seems good if you 'count', the "total" column is quite strange... it shows an enormous number (and not the actual total). Actually it sums the sums (don't know if I'm clear) : if you put 'sum' in the view it shows you indeed this enormous strange numbers (I don't really know what it means actually) and the total is indeed the total of these numbers...
Feel free to ask me to precise this if I'm not clear enough!
Comments
#1
subscribing, this is really a blocker for this module
#2
subscribing...
#3
this looks like a great module, but I have the exact same issues, the total field just huge, and not really counting.
#4
subscribing.
I'd also like to use this function.
Currently I'm also experiencing "Count" just functioning like "Sum"
#5
subscribing..
#6
subscribing !
#7
Seems like Christmas and new year have left this queue lonesome :)
Happy new year everyone !
#8
subscribing too ! I've got the same issue!
#9
All - I am not currently working on this module (although I am likely to at some point in the future), however if anyone has time to put together a patch to fix this issue I am happy to commit it.
#10
I wanted crosstab functionality to show:
columns: workflow state
rows: organic group
data: node count
With a filter for content type.
On investigating why this didn't work out of the box I came across the following issues and implemented the solutions shown. Issues 1-3 and solutions all apply to the query() function in views_crosstab_table.inc. Patch attached.
Issue 1:
$crosstab_columns_query->fieldsdid not match$this->view->style_plugin->optionsas expected.Basically for Organic Group field:
$options['crosstab_rows'] == 'group_nid'whereas$field['field'] == 'nid'in og_ancestry table so basically$crosstab_rowswas not getting populated, giving the error:drupal_set_message(t('The Crosstab Table views style does not appear to be configured.'), 'warning');My hack for this was to add elseif statement:
// Locate the crosstab rows, column and data fields.if ($field['field'] == $options['crosstab_rows']) {
$crosstab_rows = $field;
}
// Patch for using crosstab with Organic Groups as rows
elseif ($options['crosstab_rows'] == 'group_nid' && $key == 'og_ancestry_nid') {
$crosstab_rows = $field;
}
// End patch
Preferably the conditional statements that generate
$crosstab_rows,$crosstab_columnsetc should be checking two variables that will match when expected rather than having to add this dirty hack.Issue 2: Filter arguments missing from query that generates columns
I have a filter in my view, but the query that was getting the columns (workflow states) to loop through to generate the column field was not adding the filter value. So my solution was to grab the value and add it to the db_query function:
// Run the query and collate the results.// Patch to add args to query for filters
$args = $crosstab_columns_query->get_where_args();
$results = db_query($query, $args);
// End patch
Issue 3: Totals value using SUM function instead of COUNT resulting in incorrect total value
The
$options['crosstab_operation']is switched from 'COUNT' to a 'SUM' to first generate the data values e.g. in my case how many nodes of content type A are in group J and in workflow state X. When it comes to the total however, we no longer want to use 'SUM' we want to go back to 'COUNT'. If for example you are using node.nid for the data then you want the total to beCOUNT(node.nid)notSUM(node.nid), otherwise you're adding up all your node ids hence the significantly overinflated totals. So solution/hack is to revert back to COUNT for generating the 'total' field value:// Patch to switch total operation from SUM to COUNT$total_operation = ($options['crosstab_operation'] == 'SUM') ? 'COUNT' : $options['crosstab_operation'];
$this->view->query->add_field(NULL, $total_operation . '(' . $crosstab_data['table'] . '.' . $crosstab_data['field'] . ')', $alias);
// End patch
Issue 4: group_by using the wrong field name/alias. This may be related to issue 1.
Basically in the final query my group_by was meant to be grouping my rows (Organic Groups) but it was using the field 'nid' instead of 'group_nid'. To fix this in a new module I added an implementation of hook_views_query_alter() to change the query before it was run:
function MYMODULENAME_views_query_alter(&$view, &$query) {if ($view->name == 'MYVIEWNAME' && $view->current_display == 'MYVIEWDISPLAYNAME') { //
$query->groupby[0] = 'group_nid';
}
}
So 4 crappy hacks later and its working. Hopefully this will shed some light on some issues and someone with better knowledge of the module can comment/add more elegant fixes. Patch is attached but note that these are 'hacks' for specific circumstances.
#11
Thanks for your effort I am going to try this now. In your experiance is everything workign ok? I could really use this. I use views group by and it works great.. but this is what I need.....
#12
I tried runnnig the patch and get a malformed error at line 21... still trying to make it work...
#13
I get this error with patch Parse error: syntax error, unexpected T_ELSEIF in /home/cyberfan/htdocs/sites/all/modules/views_crosstab/views_crosstab_table.inc on line 119
#14
I am now having a [rpblem filtering to only how group members....
#15
I have added a relationship and filter
(Group node (member)) Organic groups: OG: Is membership approved Yes
but I get no results.....
#16
without the filter it shows everyone on the site...
#17
No offense, but critical on Alfa code? Sjeesh. Hire someone or something if you want it that fast.
#18
no offense too.. isnt this the point of alpha to know whats critical? Cant seem to get major filter in views to work. Did you want this project to die with no development? I mean has there been too much progress that there are no critical issues allowed? Is this even being maintained anymore? Im just trying to be honest, help, and tweak my drupal. Id say its a critical issue for alpha....
#19
Valid point. 'Critical' AFAIK is for if your site is melting. An alfa module should not be on a production site.
Giving that the patch might have problems in some use cases switching to 'needs work'. Which I should have done in the first place.
#20