I'm working with getting a GROUP_CONCAT field into views for my module and I've been using this post as a guide: http://drupal.stackexchange.com/a/12364/2735
I'm almost there, having successfully added the groupby to a new field in _view_query_alter. The problem I'm having is getting that field out into views, so that it's an option in the "Fields" area of the views UI. In the SQL, according to Views, I've correctly got the GROUP BY and the GROUP_CONCAT, where the concat in the SELECT looks something like:
GROUP_CONCAT(month_id) AS months
However, when I try to get 'months' back out in _views_data, it either (a) adds the table name to 'months' as in:
SELECT mytable.field1,
mytable.months ...or (b) does not recognize the field at all in the Views UI.
In _views_data, I try defining the field with:
$data['mytable']['months']
which produces (a), and with:
$data['']['months']
which produces (b). I know I'm missing something small here. Can anyone tell me what it is?
Comments
Comment #1
robynover commentedComment #2
robynover commentedComment #3
robynover commentedSolved. I put the query info into a field handler instead of in views_query_alter.
Comment #4
dawehnerCool, let's mark it as well.