Download & Extend

Limit the number of fields to display

Project:Drupal core
Version:8.x-dev
Component:field system
Category:feature request
Priority:normal
Assigned:swentel
Status:needs work
Issue tags:Usability

Issue Summary

Use case: image field set to unlimited, but you only want to show the first on a teaser view. Inspired by http://realize.be/limit-number-fields-display-field-ui-display-suite and #1234618: Limit the number of fields to display. Patch forthcoming for Drupal core.

Comments

#1

subs

#4

Ok, first version of a patch, still needs work, but setting to needs review for feedback. I've attached some screenshots as well so people can have a first impression.

Things that need work:
- upgrade path: save all instance settings with limit ?
- tests: upcoming

Feedback:
- is the preprocess_field the right place or should we cut of items earlier ?

(second try - stupid double click)

AttachmentSizeStatusTest resultOperations
1234624-manage-display.png27.22 KBIgnored: Check issue status.NoneNone
1234624-manage-display-hover.png21.6 KBIgnored: Check issue status.NoneNone
1234624.patch4.15 KBIdleFAILED: [[SimpleTest]]: [MySQL] 33,601 pass(es), 0 fail(s), and 15 exception(es).View details | Re-test

#5

Great idea indeed, just a random thought, maybe this should belong to the formatting options

#6

missing a way to view all images ?

#7

@droplet: if you leave that field empty, it shows nothing.
@pcambra: possibly. Although at this point we can only form alter into that form because it's a module specific thing (unless I've missed a hook). We could introduce a new hook or another technique of course.

Also, I've been thinking about the placement of this. Maybe we could even introduce '#display-limit' as a property for any sort of element and let drupal_render() handle this in the end. Thoughts about that ?

#8

#9

Status:active» needs review

Patch is fine code-wise.
Obviously the main challenge here will be to find the right UI shape. Thus, added the 'UX review tag'. I know UX folks *love* a good brainstorm on the Field UI :-D.

We're talking about generic settings that are relevant independently of the field type and formatter, as opposed to the existing formatter settings.
For the record, and if that brings food for the discussion : other much awaited features, in addition to this "# of values to display" setting, include :
- custom markup aka "semantic fields", currently also provided by Display Suite D7 (@swentel, maybe you have a screenshot of the current UI somewhere ?)
- separator for multiple values if the markup for multiple values is inlined (comma, dash, ...)
Of interest (or not ?) for the UI considerations, all those features pertain to multi-values fields, much less to single-value fields (or non-fields)

Contrib D7 currently already clings those features (exceot maybe the 'separator' one ?) as it can on the core Field UI screen - so this is not a hypothetical case. As the above comments show, *2* different contrib modules currently provide the '# of values to display' feature.

#10

re: that markup, here's the screenshot http://realize.be/files/ds-field-template_0.png

#11

Status:needs review» needs work

The last submitted patch, 1234624.patch, failed testing.

#12

Why can't this be a formatting setting of the thing "in general"? If its potentially more, it should clearly not fit in the model shown above.

#13

It would also be nice to have an option to show random images.

For example you have a node that has 10 images attached, you could have the teaser show one random image from that node.

Right now the random function only works with the "sort" settings for the complete node. So in the teaser I could not have my events sorted by date while also showing the nodes with random images.

Any thoughts?

#14

@swentel #7,

I meant if it have 10 images and set to show 2 only. How can I view other 8 images ? There should be a link "View All Images" ?

#15

@droplet : that's out of scope IMO. But this brings an interesting point in the hairy issue of "read more" links. #823380: Read More link is always visible on teaser.

#16

Subscribe

#17

subscribing, got a keen interest in developing field formatter settings.

@14 + @15:
If a link is out of scope, then how about "and 8 more". It doesn't have to be a link, just an indication that the items being disoplayed are not all there is. Even if it's out of scope for core, I think it's a good use-case for a contrib module. Let's see if we can make it easy to hook into this.

See Field multiple limit and other modules using Field formatter settings API.

#18

Ok. I missed the topic.." but you only want to show the first on a teaser view. "

however, I don't see the patch limited settings on teaser view only. If not teaser view exclusively, my comment #14 is important. I hate what drupal does now, some of features 50% in Core, 50% in contrib module.

If only 50% functionally, it needs to rethink again. It's only 30 sites using the contrib module that do same thing.

"Reported installs: 30 sites currently report using this module."

#19

Good feature. I think "Show 1 thumb in the teaser where the full node has 4 images" is a pretty common use case and desirable feature for core. I'm imagining this as an option for each view mode (display mode), where each display mode has the default set to 'show all' (like it is now). Then you see those ugly teasers and start digging into field ui settings…

Hmm. Maybe a core default for the teaser display of the Article content type to limit to 1 would be better then :)

But discoverability of settings for fields is a general problem to be solved on a more fundamental rework of field ui and this is a great little use case to take into account then.

droplet: does a core default to 'show all' on full node already answer your concern?

nobody click here