Posted by Amitaibu on March 29, 2009 at 9:19pm
4 followers
Jump to:
| Project: | Content Construction Kit (CCK) |
| Version: | 6.x-2.x-dev |
| Component: | Views Integration |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
Here's my use case:
1) I have several CCK fields, which are defined as multiple (snap.png)
2) When I populate them, there is a correlation between each delta. Meaning that field_foo[0] should be related too field_bar[0]; field_foo[1] to field_bar[1] etc'.
3) I'd like to use Views to create a table, and I don't want to group the fields.
4) In order to remove the 'duplication' of the fields (snap1.png) resulted from not-grouping the fields, I use hook_views_render hook_views_pre_render() and manipulate the $view->result to return my required results.
So the questions is - Is there a better way to achieve this so the SQL query will return already the expected result?
| Attachment | Size |
|---|---|
| snap.png | 19.97 KB |
| snap1.png | 27.86 KB |
Comments
#1
#2
I believe the following issues are related:
- #119102: Combo field - group different fields into one
- #416154: Synchronized deltas Views integration: Filter on equal deltas in multigroups
#3
Thanks, I close this support issue as I got the answer I was looking for.
#4
For others that may need this functionality, here's how I currently manipulate the View:
<?php/**
* Implementation of hook_views_query_alter().
*
* Add WHERE clauses that will group all fields according to their delta.
*/
function XXX_views_query_alter(&$view, &$query) {
if ($view->name == 'your_view') { // <-- Your view name.
// Get the View field aliases.
$aliases= $view->field;
if (count($aliases > 1)) {
// Get the first delta alias.
$first_field = array_shift($aliases);
$first_field = $first_field->table .'.delta';
foreach ($aliases as $value) {
$query->add_where(0, $first_field .'='. $value->table .'.delta');
}
}
}
}
?>
#5
Automatically closed -- issue fixed for 2 weeks with no activity.