With the release of Drupal 7, the popular Content Construction Kit module is baked into Drupal core. Now called FieldAPI, it allows site builders to add custom data fields to content types, user accounts, comments, and more. It also supports Multi Value Fields -- add an image field to a "Gallery" content type, for example, and users can attach an unlimited number of images to each node.

Unfortunately, the awesome flexibility of unlimited multi-value fields can be a pain when it comes time to display content, especially in space-constrained teasers or listing pages. A user who attaches fifty images to their "Gallery" node can easily spam the front page with thumbnails, or even break carefully-designed layouts. Enter Field Multiple Limit, a handy module that lets you control just how many items in a multivalue field will appear when an entity is displayed.

Screenshot of administration screen

Once the module is installed, any multi-value fields will have an additional "How many values to display" option. Even Taxonomy Term fields that Drupal provides on the default Article content type can be controlled; if users are allowed to create their own taxonomy terms using free tagging, this prevents heavily-tagged articles from cluttering up the front page with dozens of tag links.

Because the display limits are implemented in a field formatter, you can set up different limits for each display mode an entity supports. For example, you might display five photos on a teaser, ten in an RSS feed, and unlimited photos in the full version of a node.

Multi-value fields with different display limits for full and teaser modes.

Field Multiple Limit is currently listed as an "Alpha" release, but its simplicity and stability make it worth checking out. It relies on Field Formatter Settings, a handy API that allows modules to add new features and settings to an existing field formatter; that module and its related projects are also a great way to quickly tweak the presentation of Drupal 7 fields. Give them a try!

Published in

If you enjoyed this Article, you may also enjoy...

Jeff Eaton

Thumbnail
Jeff Eaton is world renowned for his opinions on Content Strategy, Drupal development, bacon, gummy candy, and cats.