After discussion with dawehner, I have created this patch. Basically it does the following;
- Adds an is_groupable() method views_handler_field class that returns either TRUE or FALSE (TRUE is default)
- Adds a new paramater ($groupable_only) to the get_field_labels() method on views_plugin_display
- Adds TRUE as an arguement in the options_form method in views_plugin_style class so only fields that have is_groupable() are returned
This is just an initial idea, it might be better to have the is_groupable stored differently on the field handler, it makes sense to add this as a default though. I am also not sure about adding a parameter to the get_field_labels method. It might be better to have a new method? I didn't want to duplicate the code in get_field_labels as it needs to access the handler directly anyway.
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | views-1548948-11.patch | 656 bytes | tim.plunkett |
| #9 | 1548948-9.patch | 2.71 KB | damiankloip |
| #6 | 1548948-6.patch | 2.71 KB | damiankloip |
| #5 | 1548948-4.patch | 2.57 KB | damiankloip |
| #3 | 1548948-3.patch | 2.57 KB | damiankloip |
Comments
Comment #1
damiankloip commentedComment #2
tim.plunkettThis might be won't fix only because it will cause fatals for any module that overrides it.
However, I'm not sure that any modules are overriding it, or why they would. And this doesn't change the default behavior.
Docs nitpicks:
Needs to be one line AND under 80 chars. And should start "Determines ".
or something.
This needs an @param
Comment #3
damiankloip commentedThanks Tim. I have made these changes, plus the change of method name from 'is_groupable' to 'use_string_group_by' as suggested by dawehner.
So it just leaves the issue about if any modules are overriding this get_field_labels method? If so, we can try and do this another way.
Comment #4
damiankloip commentedComment #5
damiankloip commentedHere is a new patch removing the function signature from get_field_labels method and using func_get_args(0) instead.
Comment #6
damiankloip commentedWIth the @param back in the docblock.
Comment #7
dawehnerThis looks fine now.
From my perspective this would have caused just a notice.
Comment #8
dawehnerI'm a bit confused, isn't this option for the string groupby and not for the query? What about "as an option to group the result by in the style settings"?
Comment #9
damiankloip commentedGood point, Here we go.
Comment #10
dawehnerThanks for the fix.
Committed to 7.x-3.x and 8.x-3.x
Comment #11
tim.plunkettI continually get "Warning: func_get_arg(): Argument 0 not passed to function in views_plugin_display->get_field_labels() (line 981 of /Users/tim/www/d7/sites/all/modules/views/plugins/views_plugin_display.inc)."
func_get_arg returns FALSE on error, but still produces an error.
Comment #12
damiankloip commentedI didn't think it would throw an error here, sorry. Proposed followup patch looks good.
Comment #13
dawehnerThanks for the quickfix!
Committed to 7.x-3.x and 8.x-3.x
Comment #14.0
(not verified) commentedgrammar!