Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Would be nice to be able to show a count for a multiple value field when displayed in a View. Makes sense when there are lots of values. I might even love a feature whereby a regular 'group multiple values' field switches to a count when there are too many to show (i.e. greater than 10). not sure if that can be an option on the handler.
Comments
Comment #1
KarenS CreditAttribution: KarenS commentedThis wouldn't have (as) been easily possible in Views 1, but is very doable in Views 2.
Comment #2
iqbalbaskara CreditAttribution: iqbalbaskara commentedhello all, i'm interested in doing this too in Views 2. could anybody please share how?
thanks in advance
Comment #3
pendashteh CreditAttribution: pendashteh commentedthis would be great. the nodereferer.module already do the exact with back references.
for example you could have a column in your table that shows how many nodes of type B have refered to this node.
and i think it should be discussed on views issues not cck.
Comment #4
giorgio79 CreditAttribution: giorgio79 commentedI have just been looking for this. I believe the Field API would need to expose the item count of multi value fields to Views in order to do this.
Found several posts looking to do this in general
http://drupal.org/node/879652
http://stackoverflow.com/questions/3390947/finding-length-of-multi-value...
Also requested here deletion, sorting and paging for multi value fields:
#1267476: Multi Value Fields - paging, sorting, deletion
Comment #5
yched CreditAttribution: yched commentedViews handlers for fields are provided by the Views module in D7/D8.
Comment #6
dawehnerIn general it would help here a lot of the new handler could be inherited from the views_handler_field_field.inc but at the moment you will always render multiple values because render_item is defined. Perhaps $items could be changed right so this doesn't matter.
You can't undefine a method of a class in a subclass in php.
Comment #7
sokrplare CreditAttribution: sokrplare commentedYou can kind of accomplish this (at least in the way I needed it) using Aggregation and Count DISTINCT. This lays it out actually - http://drupal.stackexchange.com/a/44185/6581
Comment #8
kenton.r CreditAttribution: kenton.r commentedIt would be nice to have a count of multiple values available. There are times when I would use aggregation to sum the counts of values.
Comment #9
DamienMcKennaIn Drupal 8 the Views module was moved into core, so I'm moving this issue into the core issue queue.
Comment #17
LendudeGoing through old issues.
Not sure if adding a field handler for this would be the way to go here, expanding the 'Multiple field settings' in
\Drupal\views\Plugin\views\field\EntityField::multiple_options_form
with a 'count' option might work, or people could do this in a theme since you can just run this through '#theme' => 'item_list'But offering this option might help people avoid switching on aggregation which always brings a whole new set of problems
Comment #18
candelas CreditAttribution: candelas as a volunteer commentedIt would be great to have this :)
Comment #19
Liam MorlandThis would be great. In addition to count, it could sum, average, etc.
In the meantime, field_count_formatter module is useful.